[Pkg-owncloud-commits] [owncloud] 59/70: add unit tests
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:40:11 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v6.0.5RC1
in repository owncloud.
commit 851d4786912be18fda7ff90a270a88dd7ecb2d8d
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Tue Aug 5 15:55:28 2014 +0200
add unit tests
---
apps/files_encryption/tests/util.php | 49 +++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 863ea73..c93e99f 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -22,6 +22,9 @@ use OCA\Encryption;
class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
const TEST_ENCRYPTION_UTIL_USER1 = "test-util-user1";
+ const TEST_ENCRYPTION_UTIL_USER2 = "test-util-user2";
+ const TEST_ENCRYPTION_UTIL_GROUP1 = "test-util-group1";
+ const TEST_ENCRYPTION_UTIL_GROUP2 = "test-util-group2";
const TEST_ENCRYPTION_UTIL_LEGACY_USER = "test-legacy-user";
public $userId;
@@ -59,7 +62,15 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
// create test user
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
+ \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
+
+ // create groups
+ \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
+ \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
+
+ // add user 1 to group1
+ \OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
}
@@ -116,7 +127,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
public static function tearDownAfterClass() {
// cleanup test user
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
+ \OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2);
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
+ //cleanup groups
+ \OC_Group::deleteGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
+ \OC_Group::deleteGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
}
/**
@@ -504,7 +519,30 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
/**
- * @param $user
+ * @dataProvider dataProviderFortestIsMountPointApplicableToUser
+ */
+ function testIsMountPointApplicableToUser($mount, $expectedResult) {
+ self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1);
+ $dummyClass = new DummyUtilClass($this->view, self::TEST_ENCRYPTION_UTIL_USER1);
+ $result = $dummyClass->testIsMountPointApplicableToUser($mount);
+
+ $this->assertSame($expectedResult, $result);
+ }
+
+ function dataProviderFortestIsMountPointApplicableToUser() {
+ return array(
+ array(array('applicable' => array('groups' => array(), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER1))), true),
+ array(array('applicable' => array('groups' => array(), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2))), false),
+ array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP1), 'users' => array())), true),
+ array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP1), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2))), true),
+ array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP2), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2))), false),
+ array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP2), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2, 'all'))), true),
+ array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP2), 'users' => array('all'))), true),
+ );
+ }
+
+ /**
+ * @param string $user
* @param bool $create
* @param bool $password
*/
@@ -558,3 +596,12 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
}
+
+/**
+ * dummy class extends \OCA\Encryption\Util to access protected methods for testing
+ */
+class DummyUtilClass extends \OCA\Encryption\Util {
+ public function testIsMountPointApplicableToUser($mount) {
+ return $this->isMountPointApplicableToUser($mount);
+ }
+}
--
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