[Pkg-owncloud-commits] [owncloud] 73/215: Add test for setDefaultEncryptionModule

David Prévot taffit at moszumanska.debian.org
Tue May 5 01:01:25 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 4b7ae395f2fc52b3f69872d8458a7e91a3fe92ce
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Fri Apr 17 08:37:34 2015 +0200

    Add test for setDefaultEncryptionModule
---
 tests/lib/encryption/managertest.php | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/lib/encryption/managertest.php b/tests/lib/encryption/managertest.php
index 32b1eb6..c7023d7 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"

-- 
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