/** * Gets the file system for the current app. */ public function getFileSystem() { if ($this->fileSystem == null) { $this->fileSystem = FileSystemFactory::create($this->pieCrust); } return $this->fileSystem; }
public function testImportWordpress() { $fs = MockFileSystem::create()->withPagesDir()->withPostsDir(); $app = new PieCrust(array('root' => $fs->getAppRoot())); $importer = new PieCrustImporter($app); $sampleXml = PIECRUST_UNITTESTS_DATA_DIR . 'import/wordpress.test-data.2011-01-17.xml'; $importer->import('wordpress', $sampleXml, array()); // Re-create the app to load from the new values. $app = new PieCrust(array('root' => $fs->getAppRoot())); // Check the content. $pcFs = FileSystemFactory::create($app); $pageFiles = $pcFs->getPageFiles(); $this->assertCount(11, $pageFiles); $postFiles = $pcFs->getPostFiles('blog'); $this->assertCount(22, $postFiles); }
public function testGetPageFiles() { $fs = MockFileSystem::create()->withPage('test1')->withPage('testxml.xml')->withPage('foo/test2')->withPage('foo/testtxt.txt')->withPage('foo/bar/test3')->withPage('foo/test-stuff')->withPage('bar/blah')->withPage('_tag')->withPage('_category')->withPage('otherblog/_tag')->withPage('otherblog/_category')->withPageAsset('bar/blah', 'something.txt')->withAsset('_content/pages/.whatever', 'fake')->withAsset('_content/pages/.DS_Store', 'fake')->withAsset('_content/pages/.svn/blah', 'fake')->withAsset('_content/pages/Thumbs.db', 'fake')->withAsset('_content/pages/foo/.DS_Store', 'fake')->withAsset('_content/pages/foo/Thumbs.db', 'fake')->withAsset('_content/pages/foo/test-stuff.html~', 'fake')->withAsset('_content/pages/foo/.svn/blah', 'fake'); $pc = new MockPieCrust(); $pc->setPagesDir($fs->url('kitchen/_content/pages')); $pc->getConfig()->setValue('site/posts_fs', 'flat'); $pc->getPluginLoader()->fileSystems = array(new \PieCrust\IO\FlatFileSystem(), new \PieCrust\IO\ShallowFileSystem(), new \PieCrust\IO\HierarchicalFileSystem()); $pcFs = FileSystemFactory::create($pc); $pageFiles = $pcFs->getPageFiles(); foreach ($pageFiles as &$pf) { // Fix slash/backslash problems on Windows that make // the test fail (PHP won't care about it so it's // functionally the same AFAIK). $pf->path = str_replace('\\', '/', $pf->path); $pf->relativePath = str_replace('\\', '/', $pf->relativePath); } $rootDir = $fs->url('kitchen/_content/pages'); $expected = array(new PageInfo($rootDir, $fs->url('kitchen/_content/pages/test1.html')), new PageInfo($rootDir, $fs->url('kitchen/_content/pages/testxml.xml')), new PageInfo($rootDir, $fs->url('kitchen/_content/pages/foo/test2.html')), new PageInfo($rootDir, $fs->url('kitchen/_content/pages/foo/testtxt.txt')), new PageInfo($rootDir, $fs->url('kitchen/_content/pages/foo/bar/test3.html')), new PageInfo($rootDir, $fs->url('kitchen/_content/pages/foo/test-stuff.html')), new PageInfo($rootDir, $fs->url('kitchen/_content/pages/bar/blah.html'))); $this->assertEquals($expected, $pageFiles); }