summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests/hooks.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/tests/hooks.php')
-rw-r--r--apps/files_encryption/tests/hooks.php45
1 files changed, 25 insertions, 20 deletions
diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php
index c7353deee22..1ff3ac6619b 100644
--- a/apps/files_encryption/tests/hooks.php
+++ b/apps/files_encryption/tests/hooks.php
@@ -26,7 +26,6 @@ require_once __DIR__ . '/../lib/keymanager.php';
require_once __DIR__ . '/../lib/stream.php';
require_once __DIR__ . '/../lib/util.php';
require_once __DIR__ . '/../appinfo/app.php';
-require_once __DIR__ . '/util.php';
use OCA\Encryption;
@@ -34,16 +33,16 @@ use OCA\Encryption;
* Class Test_Encryption_Hooks
* this class provide basic hook app tests
*/
-class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
+class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase {
const TEST_ENCRYPTION_HOOKS_USER1 = "test-encryption-hooks-user1.dot";
const TEST_ENCRYPTION_HOOKS_USER2 = "test-encryption-hooks-user2.dot";
- /**
- * @var \OC\Files\View
- */
+ /** @var \OC\Files\View */
public $user1View; // view on /data/user1/files
+ /** @var \OC\Files\View */
public $user2View; // view on /data/user2/files
+ /** @var \OC\Files\View */
public $rootView; // view on /data/user
public $data;
public $filename;
@@ -52,6 +51,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
private static $testFiles;
public static function setUpBeforeClass() {
+ parent::setUpBeforeClass();
+
// note: not using a data provider because these
// files all need to coexist to make sure the
// share keys are found properly (pattern matching)
@@ -92,13 +93,15 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create test user
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
}
- function setUp() {
+ protected function setUp() {
+ parent::setUp();
+
// set user id
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
// init filesystem view
@@ -108,8 +111,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
// init short data
$this->data = 'hats';
- $this->filename = 'enc_hooks_tests-' . uniqid() . '.txt';
- $this->folder = 'enc_hooks_tests_folder-' . uniqid();
+ $this->filename = 'enc_hooks_tests-' . $this->getUniqueID() . '.txt';
+ $this->folder = 'enc_hooks_tests_folder-' . $this->getUniqueID();
}
@@ -125,6 +128,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
$view = new \OC\Files\View('/');
$view->rmdir('public-keys');
$view->rmdir('owncloud_private_key');
+
+ parent::tearDownAfterClass();
}
function testDisableHook() {
@@ -146,7 +151,7 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
// relogin user to initialize the encryption again
$user = \OCP\User::getUser();
- \Test_Encryption_Util::loginHelper($user);
+ self::loginHelper($user);
}
@@ -171,8 +176,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
- \Test_Encryption_Util::logoutHelper();
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
+ self::logoutHelper();
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
@@ -229,8 +234,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
function testDeleteHooksForSharedFiles() {
- \Test_Encryption_Util::logoutHelper();
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
+ self::logoutHelper();
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
// remember files_trashbin state
@@ -265,8 +270,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/'
. $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
- \Test_Encryption_Util::logoutHelper();
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
+ self::logoutHelper();
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
// user2 update the shared file
@@ -296,8 +301,8 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
// cleanup
- \Test_Encryption_Util::logoutHelper();
- \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
+ self::logoutHelper();
+ self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
if ($stateFilesTrashbin) {