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.
File permissions are copied as well.
Please note that file contents will only be copied if their file size
does not exceed the given $maxFileSize which defaults to 1024 KB. In case
the file is larger file content will be mocked, see
https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles.
public static copyFromFileSystem ( string $path, |
||
$path | string | path to copy the structure from |
$baseDir | directory to add the structure to | |
$maxFileSize | integer | maximum file size of files to copy content from |
return |
/** * Set up for each test */ public function setUp() { // setup $this->root = vfsStream::setup('assets'); // Copy directory structure from file system vfsStream::copyFromFileSystem(__DIR__ . '/assets'); }
function getImageFolder() { $this->vfsRoot = vfsStream::setup('root'); mkdir(vfsStream::url('root') . '/images'); vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/source', $this->vfsRoot->getChild('images')); return vfsStream::url('root'); }
protected function setUp() { parent::setUp(); $this->root = vfsStream::setup('root', null, array('DependencyInjection')); vfsStream::copyFromFileSystem(__DIR__ . '/../../../../Resources/skeleton', $this->root); $this->extensionGenerator = new ExtensionGenerator(vfsStream::url('root/app-theme')); }
protected function setUp() { parent::setUp(); $this->root = vfsStream::setup('root', null, array('template', 'Slots' => array(), 'app' => array('Resources' => array('views' => array('MyThemeBundle' => array()))))); vfsStream::copyFromFileSystem(__DIR__ . '/../../../../Resources/skeleton', $this->root); $this->templateGenerator = new TemplateGenerator(vfsStream::url('root/app-theme')); }
public function setUp() { vfsStreamWrapper::register(); $root = new vfsStreamDirectory('root'); vfsStreamWrapper::setRoot($root); vfsStream::copyFromFileSystem(__DIR__ . '/../package'); $this->config = ['version' => '1.0.4', 'configFile' => vfsStream::url('root/app/code/community/Slovenian/LocalePackSl/etc/config.xml'), 'packageFile' => vfsStream::url('root/package.xml')]; }
/** * @dataProvider invalidFilesWithoutPermissionProvider */ public function testPermissionDeniedWhenSaveComposerFile($expected, $baseStructure, $projectRoot, $fromDir) { $this->setExpectedExceptionRegExp('Release\\IO\\Exception\\IOException', $expected); vfsStream::copyFromFileSystem($baseStructure); $fullPath = sprintf('%s/%s/%s', $this->root->getName(), $projectRoot, $fromDir); $composerIO = new ComposerIO(vfsStream::url($fullPath)); $composerIO->save($expected); }
public function setUp() { if (!self::$secureupload_obj) { self::$fs = vfsStream::setup('temporary', null, array('uploads' => array())); vfsStream::copyFromFileSystem(dirname(__FILE__) . '/__test_files'); $secure_upload_config = new SecureUPloadConfig(array('upload_folder' => vfsStream::url('temporary/uploads') . '/')); self::$secureupload_obj = new SecureUPload($secure_upload_config); $_FILES = array('single_upload' => array('name' => 'logo.png', 'type' => 'image/png', 'tmp_name' => vfsStream::url('temporary/logo.png'), 'error' => 0, 'size' => 4535), 'multiple_upload' => array('name' => array('logo.png', 'logo-second.png'), 'type' => array('image/png', 'image/png'), 'tmp_name' => array(vfsStream::url('temporary/logo.png'), vfsStream::url('temporary/logo-second.png')), 'error' => array(0, 0), 'size' => array(4535, 4535))); } }
protected function importDefaultTheme() { $baseThemeDir = __DIR__ . '/../../../../../../../../../src/RedKiteLabs/BootbusinessThemeBundle/Resources/views/Theme'; if (!is_dir($baseThemeDir)) { $baseThemeDir = __DIR__ . '/../../../../../vendor/redkite-labs/bootbusiness-theme-bundle/RedKiteLabs/BootbusinessThemeBundle/Resources/views/Theme'; if (!is_dir($baseThemeDir)) { $this->markTestSkipped('BusinessWebsiteThemeBundle is not available.'); } } vfsStream::copyFromFileSystem($baseThemeDir, $this->root); }
public function setUp() { if (!self::$fs) { self::$fs = vfsStream::setup('temporary'); vfsStream::copyFromFileSystem(dirname(dirname(__FILE__)) . '/__test_files'); self::$upload_validator_obj = new UploadValidator(); self::$upload_not_uploaded_by_http_post = new Upload(array('name' => 'foo.bar', 'type' => 'foo/bar', 'tmp_name' => vfsStream::url('temporary/foo.bar'), 'error' => 0, 'size' => 0)); self::$upload_forbidden_extension = new Upload(array('name' => 'forbidden.php', 'type' => 'text/php', 'tmp_name' => vfsStream::url('temporary/forbidden.php'), 'error' => 0, 'size' => 0)); self::$upload_logo_object = new Upload(array('name' => 'logo.png', 'type' => 'image/png', 'tmp_name' => vfsStream::url('temporary/logo.png'), 'error' => 0, 'size' => 4535)); self::$upload_mime_type_object = new Upload(array('name' => 'mime-type.jpg', 'type' => 'image/jpeg', 'tmp_name' => vfsStream::url('temporary/mime-type.jpg'), 'error' => 0, 'size' => 4)); } }
protected function setUp() { // Setup a virtual file system under thelia:// stream $this->stream = vfsStream::setup("thelia", 0777); // Copy the module fixtures vfsStream::copyFromFileSystem(__DIR__ . DS . str_replace("/", DS, static::TEST_MODULE_PATH), $this->stream); // Initialize the kernel $this->kernel = new Thelia("test", true); $this->kernel->boot(); // Then create event $this->event = new ModuleGenerateEvent("TheliaStudioTestModule"); $this->buildEvent(); }
protected function setUp() { parent::setUp(); $this->root = vfsStream::setup('root', null, array('slots', 'Slots' => array(), 'app' => array('Resources' => array('views' => array('MyThemeBundle' => array()))))); $skeletonDir = __DIR__ . '/../../../../Resources/skeleton'; if (!is_dir($skeletonDir)) { $skeletonDir = __DIR__ . '/Resources/skeleton'; if (!is_dir($skeletonDir)) { $this->markTestSkipped('skeleton dir is not available.'); } } vfsStream::copyFromFileSystem($skeletonDir, $this->root); $this->slotsGenerator = new SlotsGenerator(vfsStream::url('root/app-theme')); }
protected function setUp() { parent::setUp(); $this->fileSystem = new Filesystem(); $this->root = vfsStream::setup('root', null, array('src', 'bundle' => array())); $sensioDir = __DIR__ . '/../../../../../../../../../vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Resources/skeleton/bundle'; if (!is_dir($sensioDir)) { $sensioDir = __DIR__ . '/../../../../../vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Resources/skeleton/bundle'; if (!is_dir($sensioDir)) { $this->markTestSkipped('Sension Generator bundle is not available.'); } } vfsStream::copyFromFileSystem($sensioDir, $this->root->getChild('bundle')); //print_r(vfsStream::inspect(new \org\bovigo\vfs\visitor\vfsStreamStructureVisitor())->getStructure());exit; }
private function prepareVfs() { //virtual file system for tests vfsStreamWrapper::register(); $root = vfsStreamWrapper::setRoot(new vfsStreamDirectory("data")); // $structure = [ // 'dir1' => [ // 'file1' => 'some text content', // ], // 'dir2' => [ // 'file2' => 'some text content', // ], // ]; // // vfsStream::create($structure, $root); vfsStream::copyFromFileSystem($this->testDataPath, $root); }
/** * @test */ public function pathsAreOverlaidAndFinalDirectoryStructureCanBeQueried() { $root = vfsStream::setup('root'); $subfolder = vfsStream::newDirectory('fileadmin'); $root->addChild($subfolder); // Load fixture files and folders from disk vfsStream::copyFromFileSystem(__DIR__ . '/TypoScript/Fixtures', $subfolder, 1024 * 1024); FileStreamWrapper::init(PATH_site); FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', FALSE); // Use file functions as normal mkdir(PATH_site . 'fileadmin/test/'); $file = PATH_site . 'fileadmin/test/Foo.bar'; file_put_contents($file, 'Baz'); $content = file_get_contents($file); $this->assertSame('Baz', $content); $expectedFileSystem = array('root' => array('fileadmin' => array('ext_typoscript_setup.txt' => 'test.Core.TypoScript = 1', 'test' => array('Foo.bar' => 'Baz')))); $this->assertEquals($expectedFileSystem, vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); FileStreamWrapper::destroy(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->dir = vfsStream::setup(); vfsStream::copyFromFileSystem(__DIR__ . '/../fixtures/images', $this->dir); $dir = $this->dir; $image = $this->getMock('\\Imagine\\Image\\ImageInterface'); $image->expects($this->any())->method('save')->will($this->returnCallback(function ($destFile) use($dir) { $temp = vfsStream::newFile(basename($destFile)); $dir->addChild($temp); return TRUE; })); $imagine = $this->getMock('\\Imagine\\Image\\ImagineInterface'); $imagine->expects($this->any())->method('open')->will($this->returnValue($image)); $this->media = $this->getMock('\\Oryzone\\MediaStorage\\Model\\MediaInterface'); $this->media->expects($this->any())->method('getContext')->will($this->returnValue('default')); $this->media->expects($this->any())->method('getName')->will($this->returnValue('sample')); $this->variant = $this->getMock('\\Oryzone\\MediaStorage\\Variant\\VariantInterface'); $this->variant->expects($this->any())->method('getName')->will($this->returnValue('default')); $this->variant->expects($this->any())->method('getOptions')->will($this->returnValue(array('width' => 50, 'height' => 30, 'resize' => 'stretch'))); $this->variant->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('width', NULL, 50), array('height', NULL, 30)))); $this->provider = new ImageProvider(vfsStream::url($this->dir->getName()) . '/', $imagine); }
public function setUp() { if (!self::$upload_manager_organize_by_none) { self::$fs = vfsStream::setup('temporary', null, array('uploads' => array())); vfsStream::copyFromFileSystem(dirname(dirname(__FILE__)) . '/__test_files'); $_FILES = array('single_upload' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0), 'multiple_upload' => array('name' => array('', ''), 'type' => array('', ''), 'tmp_name' => array('', ''), 'error' => array(4, 4), 'size' => array(0, 0))); $secureupload_config_organize_by_none = new SecureUPloadConfig(array('upload_folder' => vfsStream::url('temporary/uploads') . '/')); $upload_folder_organize_by_none = new UploadFolder($secureupload_config_organize_by_none); self::$upload_manager_organize_by_none = new UploadManager($upload_folder_organize_by_none, $secureupload_config_organize_by_none); $secureupload_config_organize_by_type = new SecureUPloadConfig(array('upload_folder' => vfsStream::url('temporary/uploads') . '/', 'organize_by' => 'type')); $upload_folder_organize_by_type = new UploadFolder($secureupload_config_organize_by_type); self::$upload_manager_organize_by_type = new UploadManager($upload_folder_organize_by_type, $secureupload_config_organize_by_type); $secureupload_config_organize_by_date = new SecureUPloadConfig(array('upload_folder' => vfsStream::url('temporary/uploads') . '/', 'organize_by' => 'date')); $upload_folder_organize_by_date = new UploadFolder($secureupload_config_organize_by_date); self::$upload_manager_organize_by_date = new UploadManager($upload_folder_organize_by_date, $secureupload_config_organize_by_date); $secureupload_config_organize_by_type_then_date = new SecureUPloadConfig(array('upload_folder' => vfsStream::url('temporary/uploads') . '/', 'organize_by' => 'typeThenDate')); $upload_folder_organize_by_type_then_date = new UploadFolder($secureupload_config_organize_by_type_then_date); self::$upload_manager_organize_by_type_then_date = new UploadManager($upload_folder_organize_by_type_then_date, $secureupload_config_organize_by_type_then_date); $secureupload_config_organize_by_date_then_type = new SecureUPloadConfig(array('upload_folder' => vfsStream::url('temporary/uploads') . '/', 'organize_by' => 'dateThenType')); $upload_folder_organize_by_date_then_type = new UploadFolder($secureupload_config_organize_by_date_then_type); self::$upload_manager_organize_by_date_then_type = new UploadManager($upload_folder_organize_by_date_then_type, $secureupload_config_organize_by_date_then_type); } }
protected function importDefaultTheme($overrideTemplate = false) { $baseThemeDir = __DIR__ . '/../../../../../../../../../src/RedKiteLabs/BootbusinessThemeBundle/Resources/views'; if (!is_dir($baseThemeDir)) { $baseThemeDir = __DIR__ . '/../../../../../vendor/redkite-labs/bootbusiness-theme-bundle/RedKiteLabs/BootbusinessThemeBundle/Resources/views'; if (!is_dir($baseThemeDir)) { $this->markTestSkipped('BootbusinessThemeBundle is not available.'); } } vfsStream::copyFromFileSystem($baseThemeDir . '/Theme', $this->root->getChild('Theme')); vfsStream::copyFromFileSystem($baseThemeDir . '/Slots', $this->root->getChild('Slots')); }
public function copyFromFileSystem($path) { vfsStream::copyFromFileSystem($path); }
function let() { vfsStream::setup('test'); vfsStream::copyFromFileSystem(__DIR__ . '/MockFilesystem'); $this->beConstructedWith(vfsStream::url('test')); }
protected function setUpFilesystem() { $this->root = vfsStream::setup('data'); vfsStream::copyFromFileSystem(ROOT . 'tests/db'); }
/** * @test */ public function getFileReturnsCorrectIdentifier() { $root = vfsStream::setup(); $subFolder = vfsStream::newDirectory('fileadmin'); $root->addChild($subFolder); // Load fixture files and folders from disk $directory = vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024); FileStreamWrapper::init(PATH_site); FileStreamWrapper::registerOverlayPath('fileadmin/', 'vfs://root/fileadmin/', false); $subject = $this->createDriver(array('basePath' => PATH_site . 'fileadmin')); $subdirFileInfo = $subject->getFileInfoByIdentifier('Dummy.html'); $this->assertEquals('/Dummy.html', $subdirFileInfo['identifier']); $rootFileInfo = $subject->getFileInfoByIdentifier('LocalDriverFilenameFilter.php'); $this->assertEquals('/LocalDriverFilenameFilter.php', $rootFileInfo['identifier']); FileStreamWrapper::destroy(); }
/** * @param bool $copy * @return string */ protected function getPath($copy = true) { $dir = VFS::setup('test'); if ($copy) { VFS::copyFromFileSystem(__DIR__, $dir); } return VFS::url('test'); }
protected function setUp() { $this->vfs = vfsStream::setup(); vfsStream::copyFromFileSystem(__DIR__ . '/../Fixtures/filesystem'); }
/** * @test * it should map pretty permalinks to root index file * @dataProvider prettyPermalinks */ public function it_should_map_pretty_permalinks_to_root_index_file($uri) { $this->root = vfsStream::copyFromFileSystem(codecept_data_dir('folder-structures/wp-root-folder-1')); $sut = $this->make_instance(); $indexFile = $sut->getIndexForUri($uri); $expected = $this->root->url() . '/index.php'; $this->assertEquals($expected, $indexFile); }