You are here

public static function vfsStream::setup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php \org\bovigo\vfs\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

72 calls to vfsStream::setup()
DirectoryIterationTestCase::recursiveDirectoryIterationWithDotsDisabled in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php
@test @group issue_50
DirectoryIterationTestCase::recursiveDirectoryIterationWithDotsEnabled in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php
@test @group issue_50
DrupalComponentTest::testAssertNoCoreUseage in core/tests/Drupal/Tests/Component/DrupalComponentTest.php
@covers \Drupal\Tests\Component\DrupalComponentTest::assertNoCoreUsage @dataProvider providerAssertNoCoreUseage
DrupalKernelTest::testFindSitePath in core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
Tests site path finding.
FileItemValidationTest::testFileValidationConstraint in core/modules/file/tests/src/Kernel/FileItemValidationTest.php
@covers \Drupal\file\Plugin\Validation\Constraint\FileValidationConstraint @covers \Drupal\file\Plugin\Validation\Constraint\FileValidationConstraintValidator @dataProvider getFileTypes

... See full list

File

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

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)));
}