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',
)
)
the resulting directory tree will look like this:
baseDir \- Core |- badlocation.php |- AbstractFactory | |- test.php | |- other.php | \- Invalid.csv \- AnEmptyFolderArrays will become directories with their key as directory name, and strings becomes files with their key as file name and their value as file content. If no baseDir is given it will try to add the structure to the existing root directory without replacing existing childs except those with equal names.
public static function create(array $structure, vfsStreamDirectory $baseDir = null)
{
if (null === $baseDir) {
$baseDir = vfsStreamWrapper::getRoot();
}
if (null === $baseDir) {
throw new \InvalidArgumentException('No baseDir given and no root directory set.');
}
return self::addStructure($structure, $baseDir);
}
/** * @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'); }