4 * @runTestsInSeparateProcess
6 class templateTest
extends PHPUnit_Framework_TestCase
8 public function testInit()
12 foreach (glob("tmp/*") as $file) {
18 * @dataProvider tplProvider
20 public function testRuntime($test_file, $data, $expected)
23 $output = Haanga
::Load($test_file, $data, TRUE);
24 /*$output = str_replace(" ", '\s', $output);
25 $expected = str_replace(" ", '\s', $expected);/**/
26 $this->assertEquals($output, $expected);
30 * @dataProvider tplProvider
32 public function testIsCached($test_file, $data, $expected)
34 /* same as above, but we ensure that the file wasn't compiled */
36 $output = Haanga
::Load($test_file, $data, TRUE);
37 $this->assertEquals($output, $expected);
38 $this->assertFalse(Haanga
::$has_compiled);
43 * @dataProvider tplProvider
45 public function testCLICompiler($test_file, $data, $expected)
48 $GLOBALS['argv'][1] = $test_file;
49 $GLOBALS['argv'][2] = '--notags';
52 Haanga_Compiler
::main_cli();
53 $code = ob_get_clean();
57 $file = basename($test_file);
58 $pos = strpos($file,'.');
59 $function = substr($file, 0, $pos).'_template';
60 $output = call_user_func($function, $data, TRUE);
62 $this->assertEquals($output, $expected);
65 public function tplProvider()
68 foreach (glob("assert_templates/*.tpl") as $test_file) {
70 $data_file = substr($test_file, 0, -3)."php";
71 $expected = substr($test_file, 0, -3)."html";
72 if (!is_file($expected)) {
73 if (!is_file($expected.".php")) {
79 $expected = ob_get_clean();
81 $expected = file_get_contents($expected);
84 if (is_file($data_file)) {
87 } Catch (Exception
$e) {
91 $datas[] = array($test_file, $data, $expected);