If the given content is null it will fall back to use the current root
directory of the stream wrapper.
Returns given visitor for method chaining comfort.
public static inspect ( org\bovigo\vfs\visitor\vfsStreamVisitor $visitor, org\bovigo\vfs\vfsStreamContent $content = null ) : org\bovigo\vfs\visitor\vfsStreamVisitor | ||
$visitor | org\bovigo\vfs\visitor\vfsStreamVisitor | the visitor who inspects |
$content | org\bovigo\vfs\vfsStreamContent | directory structure to inspect |
return | org\bovigo\vfs\visitor\vfsStreamVisitor |
public function testConstruct() { $this->assertFileExists($this->configDir->url() . DIRECTORY_SEPARATOR . 'test'); unset($configHandler); new ConfigFileHandler('test-process', $this->configDirPath); $this->assertEquals(['root' => ['test' => []]], vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); }
/** * @dataProvider pagesProvider */ public function testPageEdit($values, $events, $logs, $expectedPage) { $pages = array("new-page-1" => array("admin.json" => '{"name":"new-page-1","currentName":"new-page-1","template":"home","isHome":false}', "page.json" => '{"name":"new-page-1","currentName":"new-page-1","template":"home","isHome":false}', "en_GB" => array("admin.json" => '{"permalink":"en-gb-new-page-1","title":"new-page-1-title","description":"new-page-1-description","keywords":"new-page-1-keywords","sitemap_frequency":"monthly","sitemap_priority":"0.5"}'))); $this->init($pages); $this->initDispatcherAndLogger($events, $logs); $this->pageManger->contributor('admin')->edit($values); $structure = vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure(); $this->assertEquals($expectedPage, $structure["localhost"]["pages"]["pages"]); }
/** * @test */ public function write() { $messages = 'Messages will be here'; $printer = $this->createPrinter($this->validRoot->url()); $printer->write($messages); $expectedStructure = vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure(); // Assert that string was written $this->assertEquals(['root' => ['test.json' => $messages]], $expectedStructure); }
public function testBuildSiteHandlingTheme() { $folders = array('RedKiteCMS' => array('app' => array('cache' => array(), 'config' => array(), 'data' => array('redkitecms.com' => array('config' => array(), 'pages' => array('pages' => array()), 'roles' => array(), 'slots' => array(), 'users' => array())), 'logs' => array(), 'plugins' => array('RedKiteCms' => array('Block' => array(), 'Theme' => array())), 'RedKiteCms.php' => 'class RedKiteCms extends RedKiteCmsBase{}'), 'src' => array(), 'web' => array())); vfsStream::setup('www', null, $folders); $siteBuilder = new SiteBuilder(vfsStream::url('www/RedKiteCMS'), 'redkitecms.com'); $siteBuilder->theme("FooTheme")->handleTheme(true)->build(); $structure = vfsStream::inspect(new \org\bovigo\vfs\visitor\vfsStreamStructureVisitor())->getStructure(); $siteStructure = array("redkitecms.com" => array("config" => array(), "pages" => array("pages" => array()), "roles" => array("roles.json" => '["ROLE_ADMIN"]'), "slots" => array(), "users" => array("users.json" => '{"admin":{"roles":["ROLE_ADMIN"],"password":"******","salt":"q4mfgrnsn2occ4kw4k008cskkwkg800"}}'), "RedKiteCms.php" => 'class RedKiteCms extends RedKiteCmsBase{}', "site.json" => '{"theme":"FooTheme","homepage":"homepage","locale_default":"en_GB","homepage_permalink":"en-gb-homepage","languages":["en_GB"],"handled_theme":"FooTheme"}', "incomplete.json" => null)); $this->assertEquals($siteStructure, $structure["www"]["RedKiteCMS"]["app"]["data"]); }
/** * @test */ public function windowsPathsCanBeProcessed() { $cRoot = 'C:\\Windows\\Root\\Path\\'; $root = vfsStream::setup('root'); FileStreamWrapper::init($cRoot); FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin'); touch($cRoot . 'fileadmin\\someFile.txt'); $expectedFileStructure = array('root' => array('fileadmin' => array('someFile.txt' => NULL))); $this->assertEquals($expectedFileStructure, vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); FileStreamWrapper::destroy(); }
/** * @covers ::bootEnvironment */ public function testBootEnvironment() { $this->assertRegExp('/^simpletest\d{6}$/', $this->databasePrefix); $this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory); $this->assertEquals(array( 'root' => array( 'sites' => array( 'simpletest' => array( substr($this->databasePrefix, 10) => array( 'files' => array( 'config' => array( 'staging' => array(), ), ), ), ), ), ), ), vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); }
/** * @covers exportToFile * @covers importFromFile */ public function testBackupRestore() { $file = $this->source->exportToFile(); // Move the file to the tmp directory so we can use command line untar. $tarball = tempnam('/tmp', 'bamtest'); copy($file->realpath(), $tarball); // Untar the file and see if all of the files are there. $this->_compareTarballToFilelist($this->file_list['files'], $tarball); // Restore to another directory. $source = new FileDirectorySource(new Config(['directory' => 'vfs://root/restore/'])); $source->setArchiveWriter(new \BackupMigrate\Core\Service\TarArchiveWriter()); $source->setArchiveReader(new \BackupMigrate\Core\Service\TarArchiveReader()); $source->setTempFileManager($this->manager); $source->importFromFile($file); $result = vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure(); $this->assertEquals($this->file_list['files'], $result['root']['restore']); // Clean up unlink($tarball); }
/** * Dumps the current state of the virtual filesystem to STDOUT. */ protected function vfsDump() { vfsStream::inspect(new vfsStreamPrintVisitor()); }
public function getStructure() { return vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure(); }
public function dumpFilesystemStructure() { vfsStream::inspect(new vfsStreamPrintVisitor()); }
public function testCmsHasBeenBootstrapped() { $this->initContainer(); $themeSlots = $this->getMock('\\RedKiteLabs\\ThemeEngineBundle\\Core\\ThemeSlots\\ThemeSlotsInterface'); $themeSlots->expects($this->once())->method('getSlots')->will($this->returnValue(array())); $activeTheme = $this->getMock('RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\ActiveTheme\\ActiveThemeInterface'); $activeTheme->expects($this->once())->method('getThemeBootstrapVersion')->will($this->returnValue('2.x')); $theme = $this->getMockBuilder('RedKiteLabs\\ThemeEngineBundle\\Core\\Theme\\Theme')->disableOriginalConstructor()->getMock(); $theme->expects($this->once())->method('getThemeSlots')->will($this->returnValue($themeSlots)); $activeTheme->expects($this->once())->method('getActiveThemeBackend')->will($this->returnValue($theme)); $this->container->expects($this->at(2))->method('get')->with('red_kite_cms.active_theme')->will($this->returnValue($activeTheme)); $this->container->expects($this->at(3))->method('getParameter')->with('red_kite_labs_theme_engine.deploy_bundle')->will($this->returnValue('@AcmeWebSiteBundle')); $this->container->expects($this->at(4))->method('getParameter')->with('red_kite_cms.deploy_bundle.assets_base_dir')->will($this->returnValue('asset-base-dir')); $this->container->expects($this->at(5))->method('getParameter')->with('red_kite_cms.deploy_bundle.media_dir')->will($this->returnValue('media')); $this->container->expects($this->at(6))->method('getParameter')->with('red_kite_cms.deploy_bundle.js_dir')->will($this->returnValue('js')); $this->container->expects($this->at(7))->method('getParameter')->with('red_kite_cms.deploy_bundle.css_dir')->will($this->returnValue('css')); $this->container->expects($this->at(8))->method('getParameter')->with('red_kite_cms.upload_assets_full_path')->will($this->returnValue(vfsStream::url('root/cms-assets/uploades-base-dir'))); $this->container->expects($this->at(9))->method('getParameter')->with('red_kite_cms.deploy_bundle.media_dir')->will($this->returnValue('media')); $this->container->expects($this->at(10))->method('getParameter')->with('red_kite_cms.deploy_bundle.js_dir')->will($this->returnValue('js')); $this->container->expects($this->at(11))->method('getParameter')->with('red_kite_cms.deploy_bundle.css_dir')->will($this->returnValue('css')); $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request'); $this->container->expects($this->at(12))->method('get')->with('request')->will($this->returnValue($request)); $this->container->expects($this->at(13))->method('get')->with('red_kite_cms.data_manager')->will($this->returnValue($this->dataManager)); $templateManager = $this->getMockBuilder('RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Content\\Template\\TemplateManager')->disableOriginalConstructor()->getMock(); $this->container->expects($this->at(14))->method('get')->with('red_kite_cms.template_manager')->will($this->returnValue($templateManager)); $pageBlocks = $this->getMock('RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Content\\PageBlocks\\PageBlocksInterface'); $this->container->expects($this->at(15))->method('get')->with('red_kite_cms.page_blocks')->will($this->returnValue($pageBlocks)); $this->container->expects($this->at(16))->method('get')->with('red_kite_cms.repeated_slots_aligner')->will($this->returnValue($this->aligner)); $twig = $this->getMock('\\Twig_Environment'); $twig->expects($this->at(0))->method('addGlobal')->with('bootstrap_version', '2.x'); $twig->expects($this->at(1))->method('addGlobal')->with('cms_language'); $this->container->expects($this->at(17))->method('get')->with('twig')->will($this->returnValue($twig)); $configuration = $this->getMock('RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Configuration\\ConfigurationInterface'); $configuration->expects($this->once())->method('read')->with('language'); $this->container->expects($this->at(18))->method('get')->with('red_kite_cms.configuration')->will($this->returnValue($configuration)); $this->container->expects($this->at(19))->method('get')->with('twig')->will($this->returnValue($twig)); $this->setupFolders(); $this->kernel->expects($this->once())->method('locateResource')->will($this->returnValue(vfsStream::url('root/frontend-assets'))); $this->pageTree->expects($this->once())->method('setDataManager')->will($this->returnSelf()); $this->pageTree->expects($this->once())->method('setup')->with($theme, $templateManager, $pageBlocks); $template = $this->getMockBuilder('RedKiteLabs\\ThemeEngineBundle\\Core\\Template\\Template')->disableOriginalConstructor()->getMock(); $this->pageTree->expects($this->once())->method('getTemplate')->will($this->returnValue($template)); $this->aligner->expects($this->once())->method('setLanguageId')->will($this->returnSelf()); $this->aligner->expects($this->once())->method('setPageId')->will($this->returnSelf()); $this->aligner->expects($this->once())->method('align'); $expectedResult = array('root' => array('frontend-assets' => array('asset-base-dir' => array('media' => array(), 'js' => array(), 'css' => array())), 'cms-assets' => array('uploades-base-dir' => array('media' => array(), 'js' => array(), 'css' => array())))); $testListener = new CmsBootstrapListener($this->container); $testListener->onKernelRequest($this->event); $this->assertEquals($expectedResult, vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); }
public function testDoNotReplaceFiles() { $root = vfsStream::setup('project', null, array('vendor' => array('dimug' => array('locales' => array('de.yml' => 'Hallo Welt!', 'en.yml' => 'Hello world!'))), 'locales' => array('de.yml' => 'Hallo Welt!'))); $this->assertTrue($root->hasChild('locales')); $this->setUp(array(array('target' => vfsStream::url('project/locales'), 'source' => vfsStream::url('project/vendor/dimug/locales'), 'files' => array('de.yml', 'en.yml')))); $this->assertRegExp('/The target file "vfs:\\/\\/project\\/locales\\/de.yml" already exists! File skipped!/', $this->command->getDisplay()); $this->assertRegExp('/All files have been copied!/', $this->command->getDisplay()); $this->assertEquals(array('project' => array('vendor' => array('dimug' => array('locales' => array('de.yml' => 'Hallo Welt!', 'en.yml' => 'Hello world!'))), 'locales' => array('de.yml' => 'Hallo Welt!', 'en.yml' => 'Hello world!'))), vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); }
/** * Retrieves the virtual file system structure * * @return array */ protected function inspectVfs() { return vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure(); }