本文整理汇总了PHP中vfsStream::create方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream::create方法的具体用法?PHP vfsStream::create怎么用?PHP vfsStream::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vfsStream
的用法示例。
在下文中一共展示了vfsStream::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeVfs
protected function initializeVfs()
{
if (is_callable('vfsStream::create') === FALSE) {
$this->markTestSkipped('vfsStream::create() does not exist');
}
\vfsStream::create($this->vfsContents);
}
示例2: test_directory_map
public function test_directory_map()
{
$structure = array('libraries' => array('benchmark.html' => '', 'database' => array('active_record.html' => '', 'binds.html' => ''), 'email.html' => '', '0' => '', '.hiddenfile.txt' => ''));
vfsStream::create($structure, $this->_test_dir);
// test default recursive behavior
$expected = array('libraries/' => array('benchmark.html', 'database/' => array('active_record.html', 'binds.html'), 'email.html', '0'));
$this->assertEquals($expected, directory_map(vfsStream::url('testDir')));
// test detection of hidden files
$expected['libraries/'][] = '.hiddenfile.txt';
$this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE));
// test recursion depth behavior
$this->assertEquals(array('libraries/'), directory_map(vfsStream::url('testDir'), 1));
}
示例3: test_directory_map
public function test_directory_map()
{
$ds = DIRECTORY_SEPARATOR;
$structure = array('libraries' => array('benchmark.html' => '', 'database' => array('active_record.html' => '', 'binds.html' => ''), 'email.html' => '', '0' => '', '.hiddenfile.txt' => ''));
vfsStream::create($structure, $this->_test_dir);
// is_dir(), opendir(), etc. seem to fail on Windows + vfsStream when there are trailing backslashes in directory names
if (!is_dir(vfsStream::url('testDir') . DIRECTORY_SEPARATOR)) {
$this->markTestSkipped();
return;
}
// test default recursive behavior
$expected = array('libraries' . $ds => array('benchmark.html', 'database' . $ds => array('active_record.html', 'binds.html'), 'email.html', '0'));
$this->assertEquals($expected, directory_map(vfsStream::url('testDir')));
// test detection of hidden files
$expected['libraries' . $ds][] = '.hiddenfile.txt';
$this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 0, TRUE));
// test recursion depth behavior
$this->assertEquals(array('libraries' . $ds), directory_map(vfsStream::url('testDir'), 1));
}
示例4: createCastsNumericDirectoriesToStringsWithRoot
/**
* @test
* @group issue_20
* @since 0.11.0
*/
public function createCastsNumericDirectoriesToStringsWithRoot()
{
$root = vfsStream::setup();
$this->assertSame($root, vfsStream::create(array(2011 => array('test.txt' => 'some content'))));
$this->assertTrue($root->hasChild('2011'));
$directory = $root->getChild('2011');
$this->assertVfsFile($directory->getChild('test.txt'), 'some content');
}
示例5: ci_vfs_create
/**
* Create VFS content
*
* @param string File name
* @param string File content
* @param object VFS directory object
* @param mixed Optional subdirectory path or array of subs
* @return void
*/
public function ci_vfs_create($file, $content = '', $root = NULL, $path = NULL)
{
// Check for array
if (is_array($file)) {
foreach ($file as $name => $content) {
$this->ci_vfs_create($name, $content, $root, $path);
}
return;
}
// Assert .php extension if none given
if (pathinfo($file, PATHINFO_EXTENSION) == '') {
$file .= '.php';
}
// Build content
$tree = array($file => $content);
// Check for path
$subs = array();
if ($path) {
// Explode if not array
$subs = is_array($path) ? $path : explode('/', trim($path, '/'));
}
// Check for root
if (!$root) {
// Use base VFS root
$root = $this->ci_vfs_root;
}
// Handle subdirectories
while ($dir = array_shift($subs)) {
// See if subdir exists under current root
$dir_root = $root->getChild($dir);
if ($dir_root) {
// Yes - recurse into subdir
$root = $dir_root;
} else {
// No - put subdirectory back and quit
array_unshift($subs, $dir);
break;
}
}
// Create any remaining subdirectories
if ($subs) {
foreach (array_reverse($subs) as $dir) {
// Wrap content in subdirectory for creation
$tree = array($dir => $tree);
}
}
// Create tree
vfsStream::create($tree, $root);
}
示例6: getFolderListFailsIfDirectoryDoesNotExist
/**
* @test
*/
public function getFolderListFailsIfDirectoryDoesNotExist()
{
$this->setExpectedException('InvalidArgumentException', '', 1314349666);
$fixture = $this->createDriverFixture(array('basePath' => $this->getMountRootUrl()));
\vfsStream::create(array($this->basedir => array('somefile' => '')));
$fixture->getFolderList('somedir/');
}
示例7: directoryExitsTestUsingTrailingWinDirSeparator
/**
* @test
*/
public function directoryExitsTestUsingTrailingWinDirSeparator()
{
$structure = array('dir' => array('bar' => array()));
vfsStream::create($structure, $this->root);
$this->assertTrue(file_exists(vfsStream::url('root/') . 'dir\\'));
}
示例8: recursiveDirectoryIterationWithDotsDisabled
/**
* @test
* @group issue_50
*/
public function recursiveDirectoryIterationWithDotsDisabled()
{
vfsStream::disableDotfiles();
vfsStream::setup();
$structure = array('Core' => array('AbstractFactory' => array('test.php' => 'some text content', 'other.php' => 'Some more text content', 'Invalid.csv' => 'Something else'), 'AnEmptyFolder' => array(), 'badlocation.php' => 'some bad content'));
$root = vfsStream::create($structure);
$rootPath = vfsStream::url($root->getName());
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($rootPath), \RecursiveIteratorIterator::CHILD_FIRST);
$pathes = array();
foreach ($iterator as $fullFileName => $fileSPLObject) {
$pathes[] = $fullFileName;
}
$this->assertEquals(array('vfs://root' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'AbstractFactory' . DIRECTORY_SEPARATOR . 'test.php', 'vfs://root' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'AbstractFactory' . DIRECTORY_SEPARATOR . 'other.php', 'vfs://root' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'AbstractFactory' . DIRECTORY_SEPARATOR . 'Invalid.csv', 'vfs://root' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'AbstractFactory', 'vfs://root' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'AnEmptyFolder', 'vfs://root' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'badlocation.php', 'vfs://root' . DIRECTORY_SEPARATOR . 'Core'), $pathes);
}
示例9: createWithEmptyName
/**
* tests that a blank name for a block device throws an exception
* @test
* @expectedException org\bovigo\vfs\vfsStreamException
*/
public function createWithEmptyName()
{
$structure = array('topLevel' => array('thisIsAFile' => 'file contents', '[]' => 'block contents'));
$root = vfsStream::create($structure);
}