예제 #1
0
 /**
  * Make sure your configuration file doesn't contain any additional providers
  */
 protected function setUp()
 {
     parent::setUp();
     $userManager = \OC::$server->getUserManager();
     $userManager->clearBackends();
     $backend = new \Test\Util\User\Dummy();
     $userManager->registerBackend($backend);
     $backend->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1);
     $this->loginAsUser(self::TEST_PREVIEW_USER1);
     $storage = new \OC\Files\Storage\Temporary([]);
     \OC\Files\Filesystem::mount($storage, [], '/' . self::TEST_PREVIEW_USER1 . '/');
     $this->rootView = new \OC\Files\View('');
     $this->rootView->mkdir('/' . self::TEST_PREVIEW_USER1);
     $this->rootView->mkdir('/' . self::TEST_PREVIEW_USER1 . '/files');
     // We simulate the max dimension set in the config
     \OC::$server->getConfig()->setSystemValue('preview_max_x', $this->configMaxWidth);
     \OC::$server->getConfig()->setSystemValue('preview_max_y', $this->configMaxHeight);
     // Used to test upscaling
     $this->maxScaleFactor = 2;
     \OC::$server->getConfig()->setSystemValue('preview_max_scale_factor', $this->maxScaleFactor);
     // We need to enable the providers we're going to use in the tests
     $providers = ['OC\\Preview\\JPEG', 'OC\\Preview\\PNG', 'OC\\Preview\\GIF', 'OC\\Preview\\TXT', 'OC\\Preview\\Postscript'];
     \OC::$server->getConfig()->setSystemValue('enabledPreviewProviders', $providers);
     // Sample is 1680x1050 JPEG
     $this->prepareSample('testimage.jpg', 1680, 1050);
     // Sample is 2400x1707 EPS
     $this->prepareSample('testimage.eps', 2400, 1707);
     // Sample is 1200x450 PNG
     $this->prepareSample('testimage-wide.png', 1200, 450);
     // Sample is 64x64 GIF
     $this->prepareSample('testimage.gif', 64, 64);
 }
예제 #2
0
파일: file.php 프로젝트: Romua1d/core
 public function setUp()
 {
     //clear all proxies and hooks so we can do clean testing
     \OC_FileProxy::clearProxies();
     \OC_Hook::clear('OC_Filesystem');
     //disabled atm
     //enable only the encryption hook if needed
     //if(OC_App::isEnabled('files_encryption')) {
     //	OC_FileProxy::register(new OC_FileProxy_Encryption());
     //}
     //set up temporary storage
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $datadir = str_replace('local::', '', $storage->getId());
     $this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
     \OC_Config::setValue('cachedirectory', $datadir);
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     //login
     \OC_User::createUser('test', 'test');
     $this->user = \OC_User::getUser();
     \OC_User::setUserId('test');
     //set up the users dir
     $rootView = new \OC\Files\View('');
     $rootView->mkdir('/test');
     $this->instance = new \OC\Cache\File();
 }
예제 #3
0
파일: config.php 프로젝트: hjimmy/owncloud
 /**
  * Hook that mounts the given user's visible mount points
  * @param array $data
  */
 public static function initMountPointsHook($data)
 {
     $mountPoints = self::getAbsoluteMountPoints($data['user']);
     foreach ($mountPoints as $mountPoint => $options) {
         \OC\Files\Filesystem::mount($options['class'], $options['options'], $mountPoint);
     }
 }
예제 #4
0
 public function testOC()
 {
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     $storage->file_put_contents('foo.txt', 'asd');
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $this->assertTrue(file_exists('oc:///foo.txt'));
     $this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
     $this->assertEquals(array('.', '..', 'foo.txt'), scandir('oc:///'));
     file_put_contents('oc:///bar.txt', 'qwerty');
     $this->assertEquals('qwerty', $storage->file_get_contents('bar.txt'));
     $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///'));
     $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt'));
     $fh = fopen('oc:///bar.txt', 'rb');
     $this->assertSame(0, ftell($fh));
     $content = fread($fh, 4);
     $this->assertSame(4, ftell($fh));
     $this->assertSame('qwer', $content);
     $content = fread($fh, 1);
     $this->assertSame(5, ftell($fh));
     $this->assertSame(0, fseek($fh, 0));
     $this->assertSame(0, ftell($fh));
     unlink('oc:///foo.txt');
     $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
 }
예제 #5
0
 protected function setUp()
 {
     parent::setUp();
     $this->user = $this->getUniqueID();
     $storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/');
 }
예제 #6
0
 public function setUp()
 {
     $storage = new Temporary(array());
     $root = '/' . uniqid();
     Filesystem::mount($storage, array(), $root);
     $this->view = new View($root);
     $this->propagator = new \OC\Files\Cache\ChangePropagator($this->view);
 }
예제 #7
0
 protected function tearDown()
 {
     $result = \OC_User::deleteUser(self::$user);
     $this->assertTrue($result);
     \OC\Files\Filesystem::tearDown();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
예제 #8
0
 protected function tearDown()
 {
     \OC_Config::setValue('datadirectory', $this->datadir);
     \OC_User::setUserId($this->uid);
     \OC_Util::setupFS($this->uid);
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
예제 #9
0
 protected function setUp()
 {
     parent::setUp();
     $storage = new Temporary(array());
     $root = $this->getUniqueID('/');
     Filesystem::mount($storage, array(), $root);
     $this->view = new View($root);
     $this->propagator = new \OC\Files\Cache\ChangePropagator($this->view);
 }
예제 #10
0
 protected function tearDown()
 {
     \OC_User::setUserId($this->user);
     \OC_Config::setValue('cachedirectory', $this->datadir);
     // Restore the original mount point
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     parent::tearDown();
 }
예제 #11
0
 public function setUp()
 {
     $this->storage = new Temporary(array());
     Filesystem::clearMounts();
     Filesystem::mount($this->storage, array(), '/');
     $this->view = new View('');
     $this->updater = new \OC\Files\Cache\Updater($this->view);
     $this->cache = $this->storage->getCache();
 }
예제 #12
0
 protected function tearDown()
 {
     foreach ($this->storages as $storage) {
         $storage->getCache()->clear();
     }
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
예제 #13
0
 /**
  * @brief Can be set up
  * @param string $user
  * @return boolean
  * @description configure the initial filesystem based on the configuration
  */
 public static function setupFS($user = '')
 {
     //setting up the filesystem twice can only lead to trouble
     if (self::$fsSetup) {
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // load all filesystem apps before, so no setup-hook gets lost
     if (!isset($RUNTIME_NOAPPS) || !$RUNTIME_NOAPPS) {
         OC_App::loadApps(array('filesystem'));
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     \OC\Files\Filesystem::initMounts();
     if (!self::$rootMounted) {
         \OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Local', array('datadir' => $configDataDirectory), '/');
         self::$rootMounted = true;
     }
     //if we aren't logged in, there is no use to set up the filesystem
     if ($user != "") {
         \OC\Files\Filesystem::addStorageWrapper(function ($mountPoint, $storage) {
             // set up quota for home storages, even for other users
             // which can happen when using sharing
             if ($storage instanceof \OC\Files\Storage\Home) {
                 $user = $storage->getUser()->getUID();
                 $quota = OC_Util::getUserQuota($user);
                 if ($quota !== \OC\Files\SPACE_UNLIMITED) {
                     return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota));
                 }
             }
             return $storage;
         });
         $userDir = '/' . $user . '/files';
         $userRoot = OC_User::getHome($user);
         $userDirectory = $userRoot . '/files';
         if (!is_dir($userDirectory)) {
             mkdir($userDirectory, 0755, true);
             OC_Util::copySkeleton($userDirectory);
         }
         //jail the user into his "home" directory
         \OC\Files\Filesystem::init($user, $userDir);
         $fileOperationProxy = new OC_FileProxy_FileOperations();
         OC_FileProxy::register($fileOperationProxy);
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
     }
     return true;
 }
예제 #14
0
 protected function setUp()
 {
     parent::setUp();
     $this->loginAsUser();
     $this->storage = new Temporary(array());
     Filesystem::mount($this->storage, array(), '/');
     $this->view = new View('');
     $this->updater = new \OC\Files\Cache\Updater($this->view);
     $this->cache = $this->storage->getCache();
 }
예제 #15
0
 public function setUp()
 {
     parent::setUp();
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     \OC\Files\Filesystem::clearMounts();
     //login
     \OC_User::createUser('test', 'test');
     \OC::$server->getSession()->set('user_id', 'test');
     $this->storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::init('test', '');
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     \OC\Files\Filesystem::file_put_contents('file1', self::CONTENT);
     $this->config->method('getAvChunkSize')->willReturn('1024');
 }
예제 #16
0
 public function testOC()
 {
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     $storage->file_put_contents('foo.txt', 'asd');
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $this->assertTrue(file_exists('oc:///foo.txt'));
     $this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
     $this->assertEquals(array('.', '..', 'foo.txt'), scandir('oc:///'));
     file_put_contents('oc:///bar.txt', 'qwerty');
     $this->assertEquals('qwerty', $storage->file_get_contents('bar.txt'));
     $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///'));
     $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt'));
     unlink('oc:///foo.txt');
     $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
 }
예제 #17
0
파일: provider.php 프로젝트: rosarion/core
 protected function setUp()
 {
     parent::setUp();
     $userManager = \OC::$server->getUserManager();
     $userManager->clearBackends();
     $backend = new \OC_User_Dummy();
     $userManager->registerBackend($backend);
     $userId = $this->getUniqueID();
     $backend->createUser($userId, $userId);
     $this->loginAsUser($userId);
     $this->storage = new \OC\Files\Storage\Temporary([]);
     \OC\Files\Filesystem::mount($this->storage, [], '/' . $userId . '/');
     $this->rootView = new \OC\Files\View('');
     $this->rootView->mkdir('/' . $userId);
     $this->rootView->mkdir('/' . $userId . '/files');
     $this->userId = $userId;
 }
예제 #18
0
 public static function setupFS($user = '')
 {
     // configure the initial filesystem based on the configuration
     if (self::$fsSetup) {
         //setting up the filesystem twice can only lead to trouble
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // load all filesystem apps before, so no setup-hook gets lost
     if (!isset($RUNTIME_NOAPPS) || !$RUNTIME_NOAPPS) {
         OC_App::loadApps(array('filesystem'));
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     if (!self::$rootMounted) {
         \OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Local', array('datadir' => $CONFIG_DATADIRECTORY), '/');
         self::$rootMounted = true;
     }
     if ($user != "") {
         //if we aren't logged in, there is no use to set up the filesystem
         $user_dir = '/' . $user . '/files';
         $user_root = OC_User::getHome($user);
         $userdirectory = $user_root . '/files';
         if (!is_dir($userdirectory)) {
             mkdir($userdirectory, 0755, true);
         }
         //jail the user into his "home" directory
         \OC\Files\Filesystem::init($user, $user_dir);
         $quotaProxy = new OC_FileProxy_Quota();
         $fileOperationProxy = new OC_FileProxy_FileOperations();
         OC_FileProxy::register($quotaProxy);
         OC_FileProxy::register($fileOperationProxy);
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
     }
     return true;
 }
예제 #19
0
 public function setUp()
 {
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     //login
     \OC_User::createUser('test', 'test');
     $this->user = \OC_User::getUser();
     \OC_User::setUserId('test');
     \OC\Files\Filesystem::clearMounts();
     $textData = "sample file\n";
     $this->storage = new \OC\Files\Storage\Temporary(array());
     $this->storage->file_put_contents(self::TEST_CLEAN_FILENAME, $textData);
     $this->storage->file_put_contents(self::TEST_INFECTED_FILENAME, $textData);
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     $this->config['av_mode'] = \OCP\Config::getAppValue('files_antivirus', 'av_mode', null);
     $this->config['av_path'] = \OCP\Config::getAppValue('files_antivirus', 'av_path', null);
     \OCP\Config::setAppValue('files_antivirus', 'av_mode', 'executable');
     \OCP\Config::setAppValue('files_antivirus', 'av_path', __DIR__ . '/avir.sh');
 }
예제 #20
0
파일: util.php 프로젝트: pinoniq/core
 /**
  * mounting an object storage as the root fs will in essence remove the
  * necessity of a data folder being present.
  * TODO make home storage aware of this and use the object storage instead of local disk access
  *
  * @param array $config containing 'class' and optional 'arguments'
  */
 private static function initObjectStoreRootFS($config)
 {
     // check misconfiguration
     if (empty($config['class'])) {
         \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
     }
     if (!isset($config['arguments'])) {
         $config['arguments'] = array();
     }
     // instantiate object store implementation
     $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
     // mount with plain / root object store implementation
     $config['class'] = '\\OC\\Files\\ObjectStore\\ObjectStoreStorage';
     // mount object storage as root
     \OC\Files\Filesystem::initMounts();
     if (!self::$rootMounted) {
         \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/');
         self::$rootMounted = true;
     }
 }
예제 #21
0
파일: view.php 프로젝트: riso/owncloud-core
 /**
  * @dataProvider tooLongPathDataProvider
  * @expectedException \OCP\Files\InvalidPathException
  */
 public function testTooLongPath($operation, $param0 = null)
 {
     $longPath = '';
     // 4000 is the maximum path length in file_cache.path
     $folderName = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789';
     $depth = 4000 / 57;
     foreach (range(0, $depth + 1) as $i) {
         $longPath .= '/' . $folderName;
     }
     $storage = new \OC\Files\Storage\Temporary(array());
     $this->tempStorage = $storage;
     // for later hard cleanup
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $rootView = new \OC\Files\View('');
     if ($param0 === '@0') {
         $param0 = $longPath;
     }
     if ($operation === 'hash') {
         $param0 = $longPath;
         $longPath = 'md5';
     }
     call_user_func(array($rootView, $operation), $longPath, $param0);
 }
예제 #22
0
 /**
  * Test getting the storage info when the remaining
  * free storage space is less than the quota
  */
 function testGetStorageInfoWhenFreeSpaceLessThanQuota()
 {
     $homeStorage = $this->getStorageMock(12);
     $homeStorage->file_put_contents('test.txt', '01234');
     $homeStorage = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $homeStorage, 'quota' => 18));
     \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files');
     $storageInfo = \OC_Helper::getStorageInfo('');
     $this->assertEquals(12, $storageInfo['free']);
     $this->assertEquals(5, $storageInfo['used']);
     // total = free + used (because quota > total)
     $this->assertEquals(17, $storageInfo['total']);
 }
예제 #23
0
 public function testOC()
 {
     // FIXME: use proper tearDown with $this->loginAsUser() and $this->logout()
     // (would currently break the tests for some reason)
     $originalStorage = \OC\Files\Filesystem::getStorage('/');
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     $storage->file_put_contents('foo.txt', 'asd');
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $this->assertTrue(file_exists('oc:///foo.txt'));
     $this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
     $this->assertEquals(array('.', '..', 'foo.txt'), scandir('oc:///'));
     file_put_contents('oc:///bar.txt', 'qwerty');
     $this->assertEquals('qwerty', $storage->file_get_contents('bar.txt'));
     $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///'));
     $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt'));
     $fh = fopen('oc:///bar.txt', 'rb');
     $this->assertSame(0, ftell($fh));
     $content = fread($fh, 4);
     $this->assertSame(4, ftell($fh));
     $this->assertSame('qwer', $content);
     $content = fread($fh, 1);
     $this->assertSame(5, ftell($fh));
     $this->assertSame(0, fseek($fh, 0));
     $this->assertSame(0, ftell($fh));
     unlink('oc:///foo.txt');
     $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($originalStorage, array(), '/');
 }
예제 #24
0
 /**
  * Delete should fail is the source folder cant be deleted
  */
 public function testSingleStorageDeleteFolderFail()
 {
     /**
      * @var \OC\Files\Storage\Temporary | \PHPUnit_Framework_MockObject_MockObject $storage
      */
     $storage = $this->getMockBuilder('\\OC\\Files\\Storage\\Temporary')->setConstructorArgs([[]])->setMethods(['rename', 'unlink', 'rmdir'])->getMock();
     $storage->expects($this->any())->method('rmdir')->will($this->returnValue(false));
     $cache = $storage->getCache();
     Filesystem::mount($storage, [], '/' . $this->user . '/files');
     $this->userView->mkdir('folder');
     $this->userView->file_put_contents('folder/test.txt', 'foo');
     $this->assertTrue($storage->file_exists('folder/test.txt'));
     $this->assertFalse($this->userView->rmdir('folder'));
     $this->assertTrue($storage->file_exists('folder'));
     $this->assertTrue($storage->file_exists('folder/test.txt'));
     $this->assertTrue($cache->inCache('folder'));
     $this->assertTrue($cache->inCache('folder/test.txt'));
     // file should not be in the trashbin
     $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
     $this->assertEquals(0, count($results));
 }
예제 #25
0
파일: api.php 프로젝트: evanjt/core
 /**
  * Post init mount points hook for mounting simulated ext storage
  */
 public static function initTestMountPointsHook($data)
 {
     if ($data['user'] === \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1) {
         \OC\Files\Filesystem::mount(self::$tempStorage, array(), '/' . \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME);
     }
 }
예제 #26
0
 public function testDeleteGhostFolder()
 {
     $storage = new Temporary(array());
     $scanner = $storage->getScanner();
     $cache = $storage->getCache();
     $storage->mkdir('foo');
     $storage->file_put_contents('foo/foo.txt', 'bar');
     \OC\Files\Filesystem::mount($storage, array(), '/test/');
     $scanner->scan('');
     $storage->rmdir('foo');
     $this->assertTrue($cache->inCache('foo'));
     $this->assertTrue($cache->inCache('foo/foo.txt'));
     $view = new \OC\Files\View('/test');
     $rootInfo = $view->getFileInfo('');
     $this->assertEquals(3, $rootInfo->getSize());
     $view->rmdir('foo');
     $newInfo = $view->getFileInfo('');
     $this->assertFalse($cache->inCache('foo'));
     $this->assertFalse($cache->inCache('foo/foo.txt'));
     $this->assertNotEquals($rootInfo->getEtag(), $newInfo->getEtag());
     $this->assertEquals(0, $newInfo->getSize());
 }
예제 #27
0
파일: versions.php 프로젝트: nem0xff/core
 public function testRestoreCrossStorage()
 {
     $storage2 = new Temporary(array());
     \OC\Files\Filesystem::mount($storage2, array(), self::TEST_VERSIONS_USER . '/files/sub');
     $this->doTestRestore();
 }
예제 #28
0
파일: storage.php 프로젝트: anolisti/apps
 /**
  * automount paths from file hooks
  *
  * @param array $params
  */
 public static function autoMount($params)
 {
     if (!self::$enableAutomount) {
         return;
     }
     $path = $params['path'];
     if (!self::$rootView) {
         self::$rootView = new \OC\Files\View('');
     }
     self::$enableAutomount = false;
     //prevent recursion
     $supported = array('zip', 'tar.gz', 'tar.bz2', 'tgz');
     foreach ($supported as $type) {
         $ext = '.' . $type . '/';
         if (($pos = strpos(strtolower($path), $ext)) !== false) {
             $archive = substr($path, 0, $pos + strlen($ext) - 1);
             if (self::$rootView->file_exists($archive) and array_search($archive, self::$mounted) === false) {
                 $localArchive = self::$rootView->getLocalFile($archive);
                 \OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Archive', array('archive' => $localArchive), $archive . '/');
                 self::$mounted[] = $archive;
             }
         }
     }
     self::$enableAutomount = true;
 }
예제 #29
0
파일: preview.php 프로젝트: Romua1d/core
 private function initFS()
 {
     // create a new user with his own filesystem view
     // this gets called by each test in this test class
     $user = uniqid();
     \OC_User::setUserId($user);
     \OC\Files\Filesystem::init($user, '/' . $user . '/files');
     \OC\Files\Filesystem::mount('OC\\Files\\Storage\\Temporary', array(), '/');
     return $user;
 }
예제 #30
0
 public function testRenameWithMountPoints()
 {
     $storage2 = new \OC\Files\Storage\Temporary(array());
     $cache2 = $storage2->getCache();
     Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
     Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
     $view = new View('/' . self::$user . '/files');
     $this->assertTrue($cache2->inCache('foo.txt'));
     $folderCachedData = $view->getFileInfo('folder');
     $substorageCachedData = $cache2->get('');
     $fooCachedData = $cache2->get('foo.txt');
     Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
     $this->assertFalse($cache2->inCache('foo.txt'));
     $this->assertTrue($cache2->inCache('bar.txt'));
     $cachedData = $cache2->get('bar.txt');
     $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
     $mtime = $cachedData['mtime'];
     $cachedData = $cache2->get('');
     $this->assertInternalType('string', $substorageCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
     // rename can cause mtime change - invalid assert
     //		$this->assertEquals($mtime, $cachedData['mtime']);
     $cachedData = $view->getFileInfo('folder');
     $this->assertInternalType('string', $folderCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
     // rename can cause mtime change - invalid assert
     //		$this->assertEquals($mtime, $cachedData['mtime']);
 }