Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. vfsStream.php

function vfsStream::setup

helper method for setting up vfsStream in unit tests

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: <code> 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', ) ) </code> the resulting directory tree will look like this: <pre> root \- Core |- badlocation.php |- AbstractFactory | |- test.php | |- other.php | \- Invalid.csv \- AnEmptyFolder </pre> 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.

@since 0.7.0

Parameters

string $rootDirName name of root directory:

int $permissions file permissions of root directory:

array $structure directory structure to add under root directory:

Return value

\org\bovigo\vfs\vfsStreamDirectory

See also

https://github.com/mikey179/vfsStream/issues/14

https://github.com/mikey179/vfsStream/issues/20

File

vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStream.php, line 164

Class

vfsStream
Some utility methods for vfsStream.

Namespace

org\bovigo\vfs

Code

public static function setup($rootDirName = 'root', $permissions = null, array $structure = array()) {
    vfsStreamWrapper::register();
    return self::create($structure, vfsStreamWrapper::setRoot(self::newDirectory($rootDirName, $permissions)));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal