summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/api.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/api.php')
-rw-r--r--apps/files_sharing/tests/api.php111
1 files changed, 4 insertions, 107 deletions
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php
index 44fc4d8b7b3..1278e0c4d1f 100644
--- a/apps/files_sharing/tests/api.php
+++ b/apps/files_sharing/tests/api.php
@@ -20,90 +20,33 @@
*
*/
-require_once __DIR__ . '/../../../lib/base.php';
+require_once __DIR__ . '/base.php';
use OCA\Files\Share;
/**
* Class Test_Files_Sharing_Api
*/
-class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
-
- const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
- const TEST_FILES_SHARING_API_USER2 = "test-share-user2";
- const TEST_FILES_SHARING_API_USER3 = "test-share-user3";
-
- public $stateFilesEncryption;
- public $filename;
- public $data;
- /**
- * @var OC_FilesystemView
- */
- public $view;
- public $folder;
-
- public static function setUpBeforeClass() {
- // reset backend
- \OC_User::clearBackends();
- \OC_User::useBackend('database');
-
- // clear share hooks
- \OC_Hook::clear('OCP\\Share');
- \OC::registerShareHooks();
- \OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
-
- // create users
- self::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1, true);
- self::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, true);
- self::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3, true);
-
- }
+class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
function setUp() {
-
- //login as user1
- \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
-
- $this->data = 'foobar';
- $this->view = new \OC_FilesystemView('/' . \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1 . '/files');
+ parent::setUp();
$this->folder = '/folder_share_api_test';
$this->filename = 'share-api-test.txt';
- // remember files_encryption state
- $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
-
- //we don't want to tests with app files_encryption enabled
- \OC_App::disable('files_encryption');
-
-
- $this->assertTrue(!\OC_App::isEnabled('files_encryption'));
-
// save file with content
$this->view->file_put_contents($this->filename, $this->data);
$this->view->mkdir($this->folder);
$this->view->file_put_contents($this->folder.'/'.$this->filename, $this->data);
-
}
function tearDown() {
$this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
- // reset app files_encryption
- if ($this->stateFilesEncryption) {
- \OC_App::enable('files_encryption');
- } else {
- \OC_App::disable('files_encryption');
- }
- }
-
- public static function tearDownAfterClass() {
- // cleanup users
- \OC_User::deleteUser(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
- \OC_User::deleteUser(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
- \OC_User::deleteUser(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3);
+ parent::tearDown();
}
/**
@@ -548,50 +491,4 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
$this->assertTrue(empty($itemsAfterDelete));
}
-
- /**
- * @param $user
- * @param bool $create
- * @param bool $password
- */
- private static function loginHelper($user, $create = false, $password = false) {
- if ($create) {
- \OC_User::createUser($user, $user);
- }
-
- if ($password === false) {
- $password = $user;
- }
-
- \OC_Util::tearDownFS();
- \OC_User::setUserId('');
- \OC\Files\Filesystem::tearDown();
- \OC_Util::setupFS($user);
- \OC_User::setUserId($user);
-
- $params['uid'] = $user;
- $params['password'] = $password;
- }
-
- /**
- * @brief get some information from a given share
- * @param int $shareID
- * @return array with: item_source, share_type, share_with, item_type, permissions
- */
- private function getShareFromId($shareID) {
- $sql = 'SELECT `item_source`, `share_type`, `share_with`, `item_type`, `permissions` FROM `*PREFIX*share` WHERE `id` = ?';
- $args = array($shareID);
- $query = \OCP\DB::prepare($sql);
- $result = $query->execute($args);
-
- $share = Null;
-
- if ($result && $result->numRows() > 0) {
- $share = $result->fetchRow();
- }
-
- return $share;
-
- }
-
}