本文整理汇总了PHP中OC\Files\View::mkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP View::mkdir方法的具体用法?PHP View::mkdir怎么用?PHP View::mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\View
的用法示例。
在下文中一共展示了View::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->user = $this->initFS();
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/' . $this->user);
$this->rootView->mkdir('/' . $this->user . '/files');
}
示例2: setUp
/**
* 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);
}
示例3: testPrepareParameters
/**
* @dataProvider prepareParametersData
*/
public function testPrepareParameters($params, $filePosition, $stripPath, $highlightParams, $expected, $createFolder = '')
{
if ($createFolder !== '') {
$this->view->mkdir('/' . \OCP\User::getUser() . '/files/' . $createFolder);
}
$this->assertEquals($expected, $this->parameterHelper->prepareParameters($params, $filePosition, $stripPath, $highlightParams));
}
示例4: setUp
protected function setUp()
{
parent::setUp();
//clear all proxies and hooks so we can do clean testing
\OC_Hook::clear('OC_Filesystem');
//set up temporary storage
$this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage, array(), '/');
$datadir = str_replace('local::', '', $storage->getId());
$config = \OC::$server->getConfig();
$this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
$config->setSystemValue('cachedirectory', $datadir);
\OC_User::clearBackends();
\OC_User::useBackend(new \Test\Util\User\Dummy());
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
//set up the users dir
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/test');
$this->instance = new \OC\Cache\File();
// forces creation of cache folder for subsequent tests
$this->instance->set('hack', 'hack');
}
示例5: testPrepareParameters
/**
* @dataProvider prepareParametersData
*/
public function testPrepareParameters($params, $filePosition, $stripPath, $highlightParams, $expected, $createFolder = '', $enableAvatars = true)
{
if ($createFolder !== '') {
$this->view->mkdir('/' . \OCP\User::getUser() . '/files/' . $createFolder);
}
$this->config->expects($this->any())->method('getSystemValue')->with('enable_avatars', true)->willReturn($enableAvatars);
$this->assertEquals($expected, $this->parameterHelper->prepareParameters($params, $filePosition, $stripPath, $highlightParams));
}
示例6: setUp
protected function setUp()
{
parent::setUp();
$this->originalStorage = \OC\Files\Filesystem::getStorage('/');
// create a new user with his own filesystem view
// this gets called by each test in this test class
$this->user = $this->getUniqueID();
\OC_User::setUserId($this->user);
\OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files');
\OC\Files\Filesystem::mount('OC\\Files\\Storage\\Temporary', array(), '/');
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/' . $this->user);
$this->rootView->mkdir('/' . $this->user . '/files');
}
示例7: doTestRestore
private function doTestRestore()
{
$filePath = self::TEST_VERSIONS_USER . '/files/sub/test.txt';
$this->rootView->file_put_contents($filePath, 'test file');
$t0 = $this->rootView->filemtime($filePath);
// not exactly the same timestamp as the file
$t1 = time() - 60;
// second version is two weeks older
$t2 = $t1 - 60 * 60 * 24 * 14;
// create some versions
$v1 = self::USERS_VERSIONS_ROOT . '/sub/test.txt.v' . $t1;
$v2 = self::USERS_VERSIONS_ROOT . '/sub/test.txt.v' . $t2;
$this->rootView->mkdir(self::USERS_VERSIONS_ROOT . '/sub');
$this->rootView->file_put_contents($v1, 'version1');
$this->rootView->file_put_contents($v2, 'version2');
$oldVersions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '/sub/test.txt');
$this->assertCount(2, $oldVersions);
$this->assertEquals('test file', $this->rootView->file_get_contents($filePath));
$info1 = $this->rootView->getFileInfo($filePath);
\OCA\Files_Versions\Storage::rollback('sub/test.txt', $t2);
$this->assertEquals('version2', $this->rootView->file_get_contents($filePath));
$info2 = $this->rootView->getFileInfo($filePath);
$this->assertNotEquals($info2['etag'], $info1['etag'], 'Etag must change after rolling back version');
$this->assertEquals($info2['fileid'], $info1['fileid'], 'File id must not change after rolling back version');
$this->assertEquals($info2['mtime'], $t2, 'Restored file has mtime from version');
$newVersions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '/sub/test.txt');
$this->assertTrue($this->rootView->file_exists(self::USERS_VERSIONS_ROOT . '/sub/test.txt.v' . $t0), 'A version file was created for the file before restoration');
$this->assertTrue($this->rootView->file_exists($v1), 'Untouched version file is still there');
$this->assertFalse($this->rootView->file_exists($v2), 'Restored version file gone from files_version folder');
$this->assertCount(2, $newVersions, 'Additional version created');
$this->assertTrue(isset($newVersions[$t0 . '#' . 'test.txt']), 'A version was created for the file before restoration');
$this->assertTrue(isset($newVersions[$t1 . '#' . 'test.txt']), 'Untouched version is still there');
$this->assertFalse(isset($newVersions[$t2 . '#' . 'test.txt']), 'Restored version is not in the list any more');
}
示例8: setUp
protected function setUp()
{
$app = new Application();
$this->container = $app->getContainer();
$this->container['AppName'] = 'core';
$this->container['AvatarManager'] = $this->getMockBuilder('OCP\\IAvatarManager')->disableOriginalConstructor()->getMock();
$this->container['Cache'] = $this->getMockBuilder('OCP\\ICache')->disableOriginalConstructor()->getMock();
$this->container['L10N'] = $this->getMockBuilder('OCP\\IL10N')->disableOriginalConstructor()->getMock();
$this->container['L10N']->method('t')->will($this->returnArgument(0));
$this->container['UserManager'] = $this->getMockBuilder('OCP\\IUserManager')->disableOriginalConstructor()->getMock();
$this->container['UserSession'] = $this->getMockBuilder('OCP\\IUserSession')->disableOriginalConstructor()->getMock();
$this->container['Request'] = $this->getMockBuilder('OCP\\IRequest')->disableOriginalConstructor()->getMock();
$this->avatarMock = $this->getMockBuilder('OCP\\IAvatar')->disableOriginalConstructor()->getMock();
$this->userMock = $this->getMockBuilder('OCP\\IUser')->disableOriginalConstructor()->getMock();
$this->avatarController = $this->container['AvatarController'];
// Store current User
$this->oldUser = \OC_User::getUser();
// Create a dummy user
$this->user = $this->getUniqueID('user');
OC::$server->getUserManager()->createUser($this->user, $this->user);
$this->loginAsUser($this->user);
// Create Cache dir
$view = new \OC\Files\View('/' . $this->user);
$view->mkdir('cache');
// Configure userMock
$this->userMock->method('getDisplayName')->willReturn($this->user);
$this->userMock->method('getUID')->willReturn($this->user);
$this->container['UserManager']->method('get')->willReturnMap([[$this->user, $this->userMock]]);
$this->container['UserSession']->method('getUser')->willReturn($this->userMock);
}
示例9: testPropagateCrossStorage
public function testPropagateCrossStorage()
{
$storage = new Temporary();
$this->view->mkdir('/foo');
Filesystem::mount($storage, [], $this->view->getAbsolutePath('/foo/submount'));
$this->view->mkdir('/foo/submount/bar');
$this->view->file_put_contents('/foo/submount/bar/sad.txt', 'qwerty');
$oldInfo1 = $this->view->getFileInfo('/');
$oldInfo2 = $this->view->getFileInfo('/foo');
$oldInfo3 = $this->view->getFileInfo('/foo/submount');
$oldInfo4 = $this->view->getFileInfo('/foo/submount/bar');
$time = time() + 50;
$this->propagator->addChange('/foo/submount/bar/sad.txt');
$this->propagator->propagateChanges($time);
$newInfo1 = $this->view->getFileInfo('/');
$newInfo2 = $this->view->getFileInfo('/foo');
$newInfo3 = $this->view->getFileInfo('/foo/submount');
$newInfo4 = $this->view->getFileInfo('/foo/submount/bar');
$this->assertEquals($newInfo1->getMTime(), $time);
$this->assertEquals($newInfo2->getMTime(), $time);
$this->assertEquals($newInfo3->getMTime(), $time);
$this->assertEquals($newInfo4->getMTime(), $time);
$this->assertNotSame($oldInfo1->getEtag(), $newInfo1->getEtag());
$this->assertNotSame($oldInfo2->getEtag(), $newInfo2->getEtag());
$this->assertNotSame($oldInfo3->getEtag(), $newInfo3->getEtag());
$this->assertNotSame($oldInfo4->getEtag(), $newInfo3->getEtag());
}
示例10: copy
/**
* Copies a file or directory.
*
* This method must work recursively and delete the destination
* if it exists
*
* @param string $source
* @param string $destination
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @return void
*/
public function copy($source, $destination)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
try {
if ($this->fileView->is_file($source)) {
$this->fileView->copy($source, $destination);
} else {
$this->fileView->mkdir($destination);
$dh = $this->fileView->opendir($source);
if (is_resource($dh)) {
while (($subNode = readdir($dh)) !== false) {
if ($subNode == '.' || $subNode == '..') {
continue;
}
$this->copy($source . '/' . $subNode, $destination . '/' . $subNode);
}
}
}
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
}
list($destinationDir, ) = \Sabre\DAV\URLUtil::splitPath($destination);
$this->markDirty($destinationDir);
}
示例11: testSizePropagationWhenRecipientChangesFile
public function testSizePropagationWhenRecipientChangesFile()
{
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
$recipientView = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
$ownerView = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$ownerView->mkdir('/sharedfolder/subfolder');
$ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
$sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
$this->assertInstanceOf('\\OC\\Files\\FileInfo', $sharedFolderInfo);
\OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
$ownerRootInfo = $ownerView->getFileInfo('', false);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->assertTrue($recipientView->file_exists('/sharedfolder/subfolder/foo.txt'));
$recipientRootInfo = $recipientView->getFileInfo('', false);
// when file changed as recipient
$recipientView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'foobar');
// size of recipient's root stays the same
$newRecipientRootInfo = $recipientView->getFileInfo('', false);
$this->assertEquals($recipientRootInfo->getSize(), $newRecipientRootInfo->getSize());
// size of owner's root increases
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
$newOwnerRootInfo = $ownerView->getFileInfo('', false);
$this->assertEquals($ownerRootInfo->getSize() + 3, $newOwnerRootInfo->getSize());
}
示例12: testDontLowerMtime
public function testDontLowerMtime() {
$time = time();
$this->view->mkdir('/foo');
$this->view->mkdir('/foo/bar');
$cache = $this->storage->getCache();
$cache->put('', ['mtime' => $time - 50]);
$cache->put('foo', ['mtime' => $time - 150]);
$cache->put('foo/bar', ['mtime' => $time - 250]);
$this->propagator->addChange('/foo/bar/foo');
$this->propagator->propagateChanges($time - 100);
$this->assertEquals(50, $time - $cache->get('')['mtime']);
$this->assertEquals(100, $time - $cache->get('foo')['mtime']);
$this->assertEquals(100, $time - $cache->get('foo/bar')['mtime']);
}
示例13: testIsExcludedPath
/**
* @dataProvider isExcludedPathProvider
*/
function testIsExcludedPath($path, $expected)
{
$this->view->mkdir(dirname($path));
$this->view->file_put_contents($path, "test");
$result = \Test_Helper::invokePrivate(new \OCA\Files_Encryption\Proxy(), 'isExcludedPath', array($path));
$this->assertSame($expected, $result);
$this->view->deleteAll(dirname($path));
}
示例14: setUp
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;
}
示例15: createDummyKeysForBackupTest
private function createDummyKeysForBackupTest()
{
// create some dummy key files
$encPath = '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '/files_encryption';
$this->view->mkdir($encPath . '/keys/foo');
$this->view->file_put_contents($encPath . '/keys/foo/fileKey', 'key');
$this->view->file_put_contents($encPath . '/keys/foo/user1.shareKey', 'share key');
}