summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorClark Tomlinson <fallen013@gmail.com>2015-02-24 13:05:19 -0500
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:27 +0200
commit39733c8da1c12cc79b7d650edf2ea1074330ee5f (patch)
tree9d072f0ebd7c0a185c5d6afeb345b5d0ae55295e /tests/lib
parent63e7fe608a5f507c5d2b417c45cf26589d091ebc (diff)
downloadnextcloud-server-39733c8da1c12cc79b7d650edf2ea1074330ee5f.tar.gz
nextcloud-server-39733c8da1c12cc79b7d650edf2ea1074330ee5f.zip
Initial commit
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/encryption/managertest.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/lib/encryption/managertest.php b/tests/lib/encryption/managertest.php
index ab297bae0cb..5a0efa37b36 100644
--- a/tests/lib/encryption/managertest.php
+++ b/tests/lib/encryption/managertest.php
@@ -111,4 +111,62 @@ class ManagerTest extends TestCase {
$en0 = $m->getEncryptionModule(0);
$this->assertEquals(0, $en0->getId());
}
+
+ /**
+ * @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException
+ * @expectedExceptionMessage At the moment it is not allowed to register more than one encryption module
+ */
+ public function testModuleRegistration() {
+ $config = $this->getMock('\OCP\IConfig');
+ $config->expects($this->any())->method('getSystemValue')->willReturn(true);
+ $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
+ $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ $m = new Manager($config);
+ $m->registerEncryptionModule($em);
+ $this->assertTrue($m->isEnabled());
+ $m->registerEncryptionModule($em);
+ }
+
+ public function testModuleUnRegistration() {
+ $config = $this->getMock('\OCP\IConfig');
+ $config->expects($this->any())->method('getSystemValue')->willReturn(true);
+ $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
+ $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ $m = new Manager($config);
+ $m->registerEncryptionModule($em);
+ $this->assertTrue($m->isEnabled());
+ $m->unregisterEncryptionModule($em);
+ $this->assertFalse($m->isEnabled());
+ }
+
+ /**
+ * @expectedException \OC\Encryption\Exceptions\ModuleDoesNotExistsException
+ * @expectedExceptionMessage Module with id: unknown does not exists.
+ */
+ public function testGetEncryptionModuleUnknown() {
+ $config = $this->getMock('\OCP\IConfig');
+ $config->expects($this->any())->method('getSystemValue')->willReturn(true);
+ $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
+ $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ $m = new Manager($config);
+ $m->registerEncryptionModule($em);
+ $this->assertTrue($m->isEnabled());
+ $m->getEncryptionModule('unknown');
+ }
+
+ public function testGetEncryptionModule() {
+ $config = $this->getMock('\OCP\IConfig');
+ $config->expects($this->any())->method('getSystemValue')->willReturn(true);
+ $em = $this->getMock('\OCP\Encryption\IEncryptionModule');
+ $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ $m = new Manager($config);
+ $m->registerEncryptionModule($em);
+ $this->assertTrue($m->isEnabled());
+ $en0 = $m->getEncryptionModule(0);
+ $this->assertEquals(0, $en0->getId());
+ }
}