public function testEntriesPaths() { $view = new View\Twig(); $view->setInputRootDir('/var/www/phrozn-test/'); $view->setInputFile('/var/www/phrozn-test/entries/some-entry.twig')->setOutputDir('/var/www/output'); $path = new OutputPath\Entry($view); $this->assertSame('/var/www/output/some-entry.html', $path->get()); $view->setInputFile('/var/www/phrozn-test/entries/sub/folder/some-entry.twig')->setOutputDir('/var/www/output'); $path->setView($view); $this->assertSame('/var/www/output/sub/folder/some-entry.html', $path->get()); $view->setInputFile('/var/www/phrozn-test/sub/folder/some-entry.twig')->setOutputDir('/var/www/output'); $path->setView($view); $this->assertSame('/var/www/output/sub/folder/some-entry.html', $path->get()); }
public function testViewCompiling() { $twig = dirname(__FILE__) . '/../project/.phrozn/entries/2011-02-24-compile.twig'; $html = dirname(__FILE__) . '/../project/.phrozn/entries/2011-02-24-compile.html'; $path = dirname(__FILE__) . '/out/'; $view = new View($twig, $path); $view->setInputRootDir(dirname(__FILE__) . '/../project/.phrozn'); $this->assertSame('2011-02-24-compile.twig', basename($view->getInputFile())); $this->assertSame('2011-02-24-compile.html', basename($view->getOutputFile())); @unlink($path . '2011-02-24-compile.html'); $this->assertFalse(is_readable($path . '2011-02-24-compile.html')); $vars = array('the_answer' => 42); $rendered = $view->compile($vars); $this->assertTrue(is_readable($path . '2011-02-24-compile.html')); $loaded = file_get_contents($html); $this->assertSame(trim($loaded), trim($rendered)); // load from out $loaded = file_get_contents($path . '2011-02-24-compile.html'); $this->assertSame(trim($loaded), trim($rendered)); // cleanup unlink($path . '2011-02-24-compile.html'); }