[Pkg-owncloud-commits] [owncloud] 72/215: Add a test that the default module is returned before we fall back

David Prévot taffit at moszumanska.debian.org
Tue May 5 01:01:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit b35379515cbac1b0163ee220104d9e0963f73346
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Fri Apr 17 07:57:32 2015 +0200

    Add a test that the default module is returned before we fall back
---
 tests/lib/encryption/managertest.php | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/tests/lib/encryption/managertest.php b/tests/lib/encryption/managertest.php
index 13f5d47..32b1eb6 100644
--- a/tests/lib/encryption/managertest.php
+++ b/tests/lib/encryption/managertest.php
@@ -21,7 +21,6 @@ class ManagerTest extends TestCase {
 		$this->config = $this->getMock('\OCP\IConfig');
 		$this->logger = $this->getMock('\OCP\ILogger');
 		$this->manager = new Manager($this->config, $this->logger);
-
 	}
 
 	public function testManagerIsDisabled() {
@@ -92,6 +91,27 @@ class ManagerTest extends TestCase {
 		$this->manager->getEncryptionModule('unknown');
 	}
 
+	public function testGetEncryptionModuleEmpty() {
+		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());
+
+		// Should return the default module
+		$defaultId = 'ID0';
+		$this->assertEquals('ID0', $this->manager->getEncryptionModule()->getId());
+		$defaultId = 'ID1';
+		$this->assertEquals('ID1', $this->manager->getEncryptionModule()->getId());
+	}
+
 	public function testGetEncryptionModule() {
 		$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
 		$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
@@ -171,4 +191,18 @@ class ManagerTest extends TestCase {
 //		$en0 = $m->getEncryptionModule(0);
 //		$this->assertEquals(0, $en0->getId());
 //	}
+
+	protected function addNewEncryptionModule(Manager $manager, $id) {
+		$encryptionModule = $this->getMock('\OCP\Encryption\IEncryptionModule');
+		$encryptionModule->expects($this->any())
+			->method('getId')
+			->willReturn('ID' . $id);
+		$encryptionModule->expects($this->any())
+			->method('getDisplayName')
+			->willReturn('TestDummyModule' . $id);
+		/** @var \OCP\Encryption\IEncryptionModule $encryptionModule */
+		$manager->registerEncryptionModule('ID' . $id, 'TestDummyModule' . $id, function() use ($encryptionModule) {
+			return $encryptionModule;
+		});
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list