コード例 #1
0
ファイル: streamwrappers.php プロジェクト: TechArea/core
 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(), '/');
 }
コード例 #2
0
 public function testOC()
 {
     $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(), '/');
 }
コード例 #3
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:///'));
 }
コード例 #4
0
 /**
  * Test getting the storage info excluding extra mount points
  * when user has no quota set, even when quota ext storage option
  * was set
  */
 function testGetStorageInfoIncludingExtStorageWithNoUserQuota()
 {
     $homeStorage = $this->getStorageMock(12);
     \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files');
     $homeStorage->file_put_contents('test.txt', '01234');
     $extStorage = new \OC\Files\Storage\Temporary(array());
     $extStorage->file_put_contents('extfile.txt', 'abcdefghijklmnopq');
     $extStorage->getScanner()->scan('');
     // update root size
     \OC\Files\Filesystem::mount($extStorage, array(), '/' . $this->user . '/files/ext');
     $config = \OC::$server->getConfig();
     $oldConfig = $config->getSystemValue('quota_include_external_storage', false);
     $config->setSystemValue('quota_include_external_storage', 'true');
     $storageInfo = \OC_Helper::getStorageInfo('');
     $this->assertEquals(12, $storageInfo['free']);
     $this->assertEquals(5, $storageInfo['used']);
     $this->assertEquals(17, $storageInfo['total']);
     $config->setSystemValue('quota_include_external_storage', $oldConfig);
 }
コード例 #5
0
ファイル: watcher.php プロジェクト: olucao/owncloud-core
 /**
  * @param bool $scan
  * @return \OC\Files\Storage\Storage
  */
 private function getTestStorage($scan = true)
 {
     $storage = new \OC\Files\Storage\Temporary(array());
     $textData = "dummy file data\n";
     $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
     $storage->mkdir('folder');
     $storage->file_put_contents('foo.txt', $textData);
     $storage->file_put_contents('foo.png', $imgData);
     $storage->file_put_contents('folder/bar.txt', $textData);
     $storage->file_put_contents('folder/bar2.txt', $textData);
     if ($scan) {
         $scanner = $storage->getScanner();
         $scanner->scan('');
     }
     $this->storages[] = $storage;
     return $storage;
 }
コード例 #6
0
ファイル: sharedstorage.php プロジェクト: evanjt/core
 public function testMoveFromStorage()
 {
     $folderInfo = $this->view->getFileInfo($this->folder);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // share 2 different files with 2 different users
     \OCP\Share::shareItem('folder', $folderInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $this->assertTrue($view->file_exists($this->folder));
     /**
      * @var \OCP\Files\Storage $sharedStorage
      */
     list($sharedStorage, ) = $view->resolvePath($this->folder);
     $this->assertTrue($sharedStorage->instanceOfStorage('OCA\\Files_Sharing\\ISharedStorage'));
     $sourceStorage = new \OC\Files\Storage\Temporary(array());
     $sourceStorage->file_put_contents('foo.txt', 'asd');
     $sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
     $this->assertTrue($sharedStorage->file_exists('bar.txt'));
     $this->assertEquals('asd', $sharedStorage->file_get_contents('bar.txt'));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->view->unlink($this->folder);
 }
コード例 #7
0
 public function testMoveFromStorage()
 {
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $share = $this->share(\OCP\Share::SHARE_TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $this->assertTrue($view->file_exists($this->folder));
     /**
      * @var \OCP\Files\Storage $sharedStorage
      */
     list($sharedStorage, ) = $view->resolvePath($this->folder);
     $this->assertTrue($sharedStorage->instanceOfStorage('OCA\\Files_Sharing\\ISharedStorage'));
     $sourceStorage = new \OC\Files\Storage\Temporary(array());
     $sourceStorage->file_put_contents('foo.txt', 'asd');
     $sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
     $this->assertTrue($sharedStorage->file_exists('bar.txt'));
     $this->assertEquals('asd', $sharedStorage->file_get_contents('bar.txt'));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->view->unlink($this->folder);
     $this->shareManager->deleteShare($share);
 }