public static function setUpBeforeClass()
 {
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCA\Files_Versions\Hooks::connectHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create test user
     self::loginHelper(self::TEST_VERSIONS_USER2, true);
     self::loginHelper(self::TEST_VERSIONS_USER, true);
 }
Exemple #2
0
 protected function setUp()
 {
     parent::setUp();
     // clear hooks
     \OC_Hook::clear();
     \OC::registerShareHooks();
     \OCA\Files_Versions\Hooks::connectHooks();
     self::loginHelper(self::TEST_VERSIONS_USER);
     $this->rootView = new \OC\Files\View();
     if (!$this->rootView->file_exists(self::USERS_VERSIONS_ROOT)) {
         $this->rootView->mkdir(self::USERS_VERSIONS_ROOT);
     }
 }
 /**
  * Test that versions are not auto-trashed when moving a file between
  * storages. This is because rename() between storages would call
  * unlink() which should NOT trigger the version deletion logic.
  */
 public function testKeepFileAndVersionsWhenMovingFolderBetweenStorages()
 {
     \OCA\Files_Versions\Hooks::connectHooks();
     $storage2 = new Temporary(array());
     \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage');
     // trigger a version (multiple would not work because of the expire logic)
     $this->userView->file_put_contents('folder/inside.txt', 'v1');
     $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
     $this->assertEquals(0, count($results));
     $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/folder/');
     $this->assertEquals(1, count($results));
     // move to another storage
     $this->userView->rename('folder', 'substorage/folder');
     $this->assertTrue($this->userView->file_exists('substorage/folder/inside.txt'));
     // rescan trash storage
     list($rootStorage, ) = $this->rootView->resolvePath($this->user . '/files_trashbin');
     $rootStorage->getScanner()->scan('');
     // versions were moved too
     $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/substorage/folder/');
     $this->assertEquals(1, count($results));
     // check that nothing got trashed by the rename's unlink() call
     $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
     $this->assertEquals(0, count($results));
     // check that versions were moved and not trashed
     $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/');
     $this->assertEquals(0, count($results));
 }
Exemple #4
0
<?php

/**
 * @author Björn Schießle <*****@*****.**>
 * @author Frank Karlitschek <*****@*****.**>
 * @author Morris Jobke <*****@*****.**>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OCP\Util::addscript('files_versions', 'versions');
OCP\Util::addStyle('files_versions', 'versions');
\OCA\Files_Versions\Hooks::connectHooks();
 protected function setUp()
 {
     parent::setUp();
     $config = \OC::$server->getConfig();
     $mockConfig = $this->getMock('\\OCP\\IConfig');
     $mockConfig->expects($this->any())->method('getSystemValue')->will($this->returnCallback(function ($key, $default) use($config) {
         if ($key === 'filesystem_check_changes') {
             return \OC\Files\Cache\Watcher::CHECK_ONCE;
         } else {
             return $config->getSystemValue($key, $default);
         }
     }));
     $this->overwriteService('AllConfig', $mockConfig);
     // clear hooks
     \OC_Hook::clear();
     \OC::registerShareHooks();
     \OCA\Files_Versions\Hooks::connectHooks();
     self::loginHelper(self::TEST_VERSIONS_USER);
     $this->rootView = new \OC\Files\View();
     if (!$this->rootView->file_exists(self::USERS_VERSIONS_ROOT)) {
         $this->rootView->mkdir(self::USERS_VERSIONS_ROOT);
     }
 }