org\bovigo\vfs\vfsStream::setup PHP Метод

setup() публичный статический Метод

Instead of vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(vfsStream::newDirectory('root')); you can simply do vfsStream::setup() which yields the same result. Additionally, the method returns the freshly created root directory which you can use to make further adjustments to it. Assumed $structure contains an array like this: 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:
root
\- Core
 |- badlocation.php
 |- AbstractFactory
 | |- test.php
 | |- other.php
 | \- Invalid.csv
 \- AnEmptyFolder
Arrays 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.
См. также: https://github.com/mikey179/vfsStream/issues/14
См. также: https://github.com/mikey179/vfsStream/issues/20
С версии: 0.7.0
public static setup ( string $rootDirName = 'root', integer $permissions = null, array $structure = [] ) : vfsStreamDirectory
$rootDirName string name of root directory
$permissions integer file permissions of root directory
$structure array directory structure to add under root directory
Результат vfsStreamDirectory
    public static function setup($rootDirName = 'root', $permissions = null, array $structure = array())
    {
        vfsStreamWrapper::register();
        return self::create($structure, vfsStreamWrapper::setRoot(self::newDirectory($rootDirName, $permissions)));
    }

Usage Example

Пример #1
0
 public function testGetTranslations_shouldReturnEmptyArray()
 {
     $root = vfsStream::setup('root');
     $root->addChild(new vfsStreamFile('language.php'));
     $obj = new Language_File(vfsStream::url('root/language.php'));
     $this->assertEquals(array(), $obj->getTranslations());
 }
All Usage Examples Of org\bovigo\vfs\vfsStream::setup