本文整理汇总了PHP中org\bovigo\vfs\vfsStream::create方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream::create方法的具体用法?PHP vfsStream::create怎么用?PHP vfsStream::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org\bovigo\vfs\vfsStream
的用法示例。
在下文中一共展示了vfsStream::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpVirtualFileAndGetPath
/**
* @param $csvContent
* @return string
*/
protected function setUpVirtualFileAndGetPath($csvContent)
{
$structure = array('directory' => array('my_file.csv' => $csvContent));
vfsStream::setup();
vfsStream::create($structure);
return vfsStream::url('root/directory/my_file.csv');
}
示例2: testLoad
/**
* Tests success case for loading a valid and readable YAML file.
*
* @covers ::load
*/
public function testLoad()
{
$initialContent = ['hello' => 'world'];
$ymlContent = Yaml::dump($initialContent);
vfsStream::create(['file1' => $ymlContent], $this->root);
$this->assertEquals($initialContent, (new YamlFileLoader())->load(vfsStream::url('test/file1')));
}
示例3: initializeVfs
protected function initializeVfs()
{
if (is_callable('org\\bovigo\\vfs\\vfsStream::create') === FALSE) {
$this->markTestSkipped('vfsStream::create() does not exist');
}
vfsStream::create($this->vfsContents);
}
示例4: testLoad
public function testLoad()
{
$initialContent = array('some content');
vfsStream::create(array('file1' => json_encode($initialContent)), $this->root);
$content = (new JsonFileLoader())->load(vfsStream::url('test/file1'));
$this->assertEquals($initialContent, $content);
}
示例5: setUp
protected function setUp()
{
$this->loader = new LayoutLoader();
$this->fileSystem = Stream::setup('root');
$files = array('handle_one_file1.php' => sprintf('<?php %s', '$this->addItem(new EcomDev_LayoutCompiler_Layout_Item_Remove("handle_one_block_one"));'), 'handle_one_file2.php' => sprintf('<?php %s', implode("\n", array('$this->addItem(new EcomDev_LayoutCompiler_Layout_Item_Remove("handle_one_block_two"));', '$this->addItem($item = new EcomDev_LayoutCompiler_Layout_Item_Remove("handle_one_block_three"));', '$this->addItemRelation($item, "handle_one_block_three");'))), 'handle_two_file1.php' => sprintf('<?php %s', implode("\n", array('$this->addItem(new EcomDev_LayoutCompiler_Layout_Item_Remove("handle_two_block_one"));'))), 'handle_three_file1.php' => sprintf('<?php '), 'handle_three_file2.php' => sprintf('<?php '), 'handle_four_file1.php' => sprintf('<?php '));
Stream::create($files, $this->fileSystem);
}
示例6: testGetCommandsList
public function testGetCommandsList()
{
$commandManager = $this->createCommandManager();
$this->assertEquals([], $commandManager->getCommandsList());
vfsStream::create(['foo.php' => '', 'bar.php' => '', 'baz' => ['baz.php' => '']], $this->commandsFolder);
$this->assertEquals(['bar', 'baz', 'foo'], $commandManager->getCommandsList());
}
示例7: testRecursiveTempDirectory
public function testRecursiveTempDirectory()
{
vfsStream::create(array('recursive' => array('a' => array('1' => 'file', 'A' => array()), 'b' => array())), $this->root);
$temp = new TempDirectory(vfsStream::url('root/recursive'), true);
unset($temp);
$this->assertFalse($this->root->hasChild('recursive'), "recursive dir and its contents must have been deleted");
}
示例8: execute
private function execute(array $fileStructure, array $options = []) : CommandTester
{
$fs = vfsStream::create($fileStructure, vfsStream::setup(getcwd()));
$commandTester = new CommandTester($this->command);
$commandTester->execute(array_merge(['command' => $this->command->getName(), 'path' => $fs->url()], $options));
return $commandTester;
}
示例9: testItLoadsMetaDataObjectsFromFile
/**
* @param $fileContent
* @param $expectedMetadataObjects
* @param $expectedMetadataHandleObjects
*
* @dataProvider dataProviderMetadataObjectsFromFile
*/
public function testItLoadsMetaDataObjectsFromFile($fileContent, $expectedMetadataObjects, $expectedMetadataHandleObjects)
{
Stream::create(array('index_test_file.php' => $fileContent), $this->virtualDirectory);
$this->index->setSavePath($this->virtualDirectory->url());
$this->assertTrue($this->index->load(array('test' => 'file')));
$this->assertAttributeEquals($expectedMetadataObjects, 'metadata', $this->index);
$this->assertAttributeEquals($expectedMetadataHandleObjects, 'metadataByHandle', $this->index);
}
示例10: createTempFile
private function createTempFile($file)
{
$url = vfsStream::url('root/' . $file);
vfsStream::create(array($file => 'a temp file'), $this->root);
$tempFile = new TempFile($url);
// unused, we just want it to destruct after function returns
$this->assertTrue($this->root->hasChild($file), "Expect we did create this file: {$file}");
}
示例11: locate_should_return_correct_results
/**
* @test
*/
public function locate_should_return_correct_results()
{
vfsStream::setup();
$root = vfsStream::create(['config' => ['config_file.yml' => 'CONTENT', 'config_file.php' => 'CONTENT', 'foo.txt' => 'CONTENT'], 'src' => ['AppBundle' => ['config' => ['configuration.yml' => 'CONTENT']]], 'web' => ['app.php' => 'CONTENT']]);
$result = $this->getLocator()->locate($root->url(), '.yml');
sort($result);
$this->assertEquals([$root->url() . '/config/config_file.yml', $root->url() . '/src/AppBundle/config/configuration.yml'], $result);
}
示例12: setupVfsStream
private function setupVfsStream()
{
$root = vfsStream::setup('root');
vfsStream::create(['tmp' => ['file.txt' => 'foobar'], 'uploads' => ['image.png' => 'image']]);
$this->sourceUrl = vfsStream::url('root/tmp/file.txt');
$this->destUrl = vfsStream::url('root/uploads');
$this->existingUrl = vfsStream::url('root/uploads/image.png');
}
示例13: mockFileSystem
/**
*
* @param array $structure
* @return string
*/
public static function mockFileSystem(array $structure) : string
{
if (empty(self::$vfsStreamRoot)) {
self::$vfsStreamRoot = vfsStream::setup('mock');
}
vfsStream::create($structure, self::$vfsStreamRoot);
return vfsStream::url('mock');
}
示例14: setUp
protected function setUp()
{
vfsStream::setup('root');
vfsStream::create(['uploads' => ['upload 0 contents', 'upload 1 contents', 'upload 2 contents', 'upload 3 contents', 'upload 4 contents']]);
$this->files = [['tmp_name' => vfsStream::url('root/uploads/0')], ['tmp_name' => vfsStream::url('root/uploads/1')], ['tmp_name' => vfsStream::url('root/uploads/2')], [], ['tmp_name' => [vfsStream::url('root/uploads/3'), vfsStream::url('root/uploads/4')]]];
is_uploaded_file('', [$this->files[0]['tmp_name'], $this->files[1]['tmp_name'], $this->files[4]['tmp_name'][0], $this->files[4]['tmp_name'][1]]);
$this->assertFilesExist();
}
示例15: createVirtualFiles
protected static function createVirtualFiles($upload_data)
{
$name_corrected_upload_data = [];
foreach ($upload_data as $k => $v) {
$name_corrected_upload_data[str_replace(self::BASE_PATH, "", $k)] = $v;
}
// vfsStream::create will take a reference, not a copy.
vfsStream::create(['uploads' => $name_corrected_upload_data]);
}