public function testVoltCompilerExtendsFile() { @unlink('unit-tests/views/layouts/test10.volt.php'); @unlink('unit-tests/views/test10/children.extends.volt.php'); $view = new Phalcon\Mvc\View(); $view->setViewsDir('unit-tests/views/'); $volt = new Compiler($view); //extends $volt->compileFile('unit-tests/views/test10/children.extends.volt', 'unit-tests/views/test10/children.extends.volt.php'); $compilation = file_get_contents('unit-tests/views/test10/children.extends.volt.php'); $this->assertEquals($compilation, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"><html lang="en"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">.important { color: #336699; }</style><title>Index - My Webpage</title></head><body><div id="content"><h1>Index</h1><p class="important">Welcome on my awesome homepage.</p></div><div id="footer">© Copyright 2012 by <a href="http://domain.invalid/">you</a>.</div></body>'); }
public function testVoltCompilerImportRecursiveFile() { @unlink('unit-tests/views/partials/header3.volt.php'); @unlink('unit-tests/views/partials/header2.volt.php'); @unlink('unit-tests/views/test10/import2.volt.php'); $view = new Phalcon\Mvc\View(); $view->setViewsDir('unit-tests/views/'); $volt = new \Phalcon\Mvc\View\Engine\Volt\Compiler($view); //extends $volt->compileFile('unit-tests/views/test10/import2.volt', 'unit-tests/views/test10/import2.volt.php'); $compilation = file_get_contents('unit-tests/views/test10/import2.volt.php'); $this->assertEquals($compilation, '<div class="header"><h1>This is the title</h1></div>'); }
public function testVoltCompilerImportRecursiveFile() { $this->specify("Volt files can't recursively import files", function () { @unlink(PATH_DATA . 'views/partials/header3.volt.php'); @unlink(PATH_DATA . 'views/partials/header2.volt.php'); @unlink(PATH_DATA . 'views/test10/import2.volt.php'); $view = new View(); $view->setViewsDir(PATH_DATA . 'views/'); $volt = new Compiler($view); //extends $volt->compileFile(PATH_DATA . 'views/test10/import2.volt', PATH_DATA . 'views/test10/import2.volt.php'); $compilation = file_get_contents(PATH_DATA . 'views/test10/import2.volt.php'); expect($compilation)->equals('<div class="header"><h1>This is the title</h1></div>'); }); }