diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-04-17 08:37:34 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-04-27 11:03:51 +0200 |
commit | 4b7ae395f2fc52b3f69872d8458a7e91a3fe92ce (patch) | |
tree | 42b4ea2b9a1b0d3c22c0304415ffdb7cb8a12735 /tests | |
parent | b35379515cbac1b0163ee220104d9e0963f73346 (diff) | |
download | nextcloud-server-4b7ae395f2fc52b3f69872d8458a7e91a3fe92ce.tar.gz nextcloud-server-4b7ae395f2fc52b3f69872d8458a7e91a3fe92ce.zip |
Add test for setDefaultEncryptionModule
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/encryption/managertest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/encryption/managertest.php b/tests/lib/encryption/managertest.php index 32b1eb6df10..c7023d78c7d 100644 --- a/tests/lib/encryption/managertest.php +++ b/tests/lib/encryption/managertest.php @@ -134,6 +134,37 @@ class ManagerTest extends TestCase { $this->assertEquals('id', $en0->getId()); } + public function testSetDefaultEncryptionModule() { + global $defaultId; + $defaultId = null; + + $this->config->expects($this->any()) + ->method('getAppValue') + ->with('core', 'default_encryption_module') + ->willReturnCallback(function() { global $defaultId; return $defaultId; }); + + $this->addNewEncryptionModule($this->manager, 0); + $this->assertCount(1, $this->manager->getEncryptionModules()); + $this->addNewEncryptionModule($this->manager, 1); + $this->assertCount(2, $this->manager->getEncryptionModules()); + + // Default module is the first we set + $defaultId = 'ID0'; + $this->assertEquals('ID0', \Test_Helper::invokePrivate($this->manager, 'getDefaultEncryptionModuleId')); + + // Set to an existing module + $this->config->expects($this->once()) + ->method('setAppValue') + ->with('core', 'default_encryption_module', 'ID1'); + $this->assertTrue($this->manager->setDefaultEncryptionModule('ID1')); + $defaultId = 'ID1'; + $this->assertEquals('ID1', \Test_Helper::invokePrivate($this->manager, 'getDefaultEncryptionModuleId')); + + // Set to an unexisting module + $this->assertFalse($this->manager->setDefaultEncryptionModule('ID2')); + $this->assertEquals('ID1', \Test_Helper::invokePrivate($this->manager, 'getDefaultEncryptionModuleId')); + } + // /** // * @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException // * @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0" |