summaryrefslogtreecommitdiffstats
path: root/tests/lib/encryption
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-14 16:48:39 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-17 10:31:33 +0200
commit7d4b1b52d08fd4bc8e9f65ca2ccc747de2fc429a (patch)
treec40489a85da1be3eb66041a2ca2719f38c0298f3 /tests/lib/encryption
parentf32d97750c33942db53a56d1deceacb2ed3e779b (diff)
downloadnextcloud-server-7d4b1b52d08fd4bc8e9f65ca2ccc747de2fc429a.tar.gz
nextcloud-server-7d4b1b52d08fd4bc8e9f65ca2ccc747de2fc429a.zip
always create a new instance of the encryption module
Diffstat (limited to 'tests/lib/encryption')
-rw-r--r--tests/lib/encryption/managertest.php41
1 files changed, 22 insertions, 19 deletions
diff --git a/tests/lib/encryption/managertest.php b/tests/lib/encryption/managertest.php
index f123f438311..13f5d47b083 100644
--- a/tests/lib/encryption/managertest.php
+++ b/tests/lib/encryption/managertest.php
@@ -36,9 +36,9 @@ class ManagerTest extends TestCase {
public function testManagerIsDisabledIfDisabledButModules() {
$this->config->expects($this->any())->method('getAppValue')->willReturn(false);
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
- $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule($em);
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function() use ($em) {return $em;});
$this->assertFalse($this->manager->isEnabled());
}
@@ -50,29 +50,32 @@ class ManagerTest extends TestCase {
/**
* @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException
- * @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0"
+ * @expectedExceptionMessage Id "id" already used by encryption module "TestDummyModule0"
*/
public function testModuleRegistration() {
$this->config->expects($this->any())->method('getAppValue')->willReturn('yes');
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
- $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule($em);
+
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;});
$this->assertSame(1, count($this->manager->getEncryptionModules()));
- $this->manager->registerEncryptionModule($em);
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;});
}
public function testModuleUnRegistration() {
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
- $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule($em);
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;});
$this->assertSame(1,
count($this->manager->getEncryptionModules())
);
- $this->manager->unregisterEncryptionModule($em);
+
+ $this->manager->unregisterEncryptionModule('id');
$this->assertEmpty($this->manager->getEncryptionModules());
+
}
/**
@@ -82,9 +85,9 @@ class ManagerTest extends TestCase {
public function testGetEncryptionModuleUnknown() {
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
- $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule($em);
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;});
$this->assertSame(1, count($this->manager->getEncryptionModules()));
$this->manager->getEncryptionModule('unknown');
}
@@ -92,23 +95,23 @@ class ManagerTest extends TestCase {
public function testGetEncryptionModule() {
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
- $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule($em);
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;});
$this->assertSame(1, count($this->manager->getEncryptionModules()));
- $en0 = $this->manager->getEncryptionModule(0);
- $this->assertEquals(0, $en0->getId());
+ $en0 = $this->manager->getEncryptionModule('id');
+ $this->assertEquals('id', $en0->getId());
}
public function testGetDefaultEncryptionModule() {
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
- $em->expects($this->any())->method('getId')->willReturn(0);
+ $em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule($em);
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;});
$this->assertSame(1, count($this->manager->getEncryptionModules()));
- $en0 = $this->manager->getEncryptionModule(0);
- $this->assertEquals(0, $en0->getId());
+ $en0 = $this->manager->getEncryptionModule('id');
+ $this->assertEquals('id', $en0->getId());
}
// /**