Esempio n. 1
0
 private function getApp($supportedFormats)
 {
     $app = new MockPieCrust();
     $app->getConfig()->set(array('site' => array('default_format' => 'doesnt_exist')));
     $loader = $app->getPluginLoader();
     $loader->formatters[] = new MockFormatter($supportedFormats);
     return $app;
 }
Esempio n. 2
0
 public function getMockApp()
 {
     $app = new MockPieCrust($this->getAppRoot() . '/');
     $app->getPluginLoader()->fileSystems = array(new \PieCrust\IO\FlatFileSystem(), new \PieCrust\IO\ShallowFileSystem(), new \PieCrust\IO\HierarchicalFileSystem());
     return $app;
 }
Esempio n. 3
0
 public function testChainedProcessors()
 {
     $fs = MockFileSystem::create(false)->withFile('something.foo', 'Some contents.')->withDir('_cache')->withDir('_counter');
     $pc = new MockPieCrust();
     $pc->rootDir = $fs->url('');
     $pc->cacheDir = $fs->url('_cache/');
     $pc->isCachingEnabled = true;
     $pc->getPluginLoader()->processors[] = new MockProcessor('uppercase', 'foo', function ($c) {
         return strtoupper($c);
     }, IProcessor::PRIORITY_HIGH);
     $pc->getPluginLoader()->processors[] = new MockProcessor('prefix', 'html', function ($c) {
         return 'prefixed: ' . $c;
     });
     $pc->getPluginLoader()->processors[] = new MockProcessor('wraptag', array('foo' => 'html'), function ($c) {
         return "<b>{$c}</b>";
     });
     $pc->getPluginLoader()->processors[] = new CopyFileProcessor();
     $bakeDir = $fs->url('_counter');
     $parameters = array('processors' => array('*'));
     $baker = new DirectoryBaker($pc, $bakeDir, $parameters);
     $outFile = $fs->url('_counter/something.html');
     $this->assertFalse(is_file($outFile));
     $baker->bake();
     $this->assertTrue(is_file($outFile));
     $this->assertEquals('prefixed: <b>SOME CONTENTS.</b>', file_get_contents($outFile));
 }
Esempio n. 4
0
 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);
 }