From cb41013e619fde6b3e74e9e0bb49607aa9e84a6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=98yvind=20gjesdal?= <oyvind@localhost.localdomain>
Date: Tue, 27 Oct 2020 14:00:01 +0100
Subject: [PATCH] add Haanga test changes

---
 lib/Haanga/.travis.yml                        |  15 ++++++
 lib/Haanga/composer.json                      |  19 ++++++++
 lib/Haanga/phpunit.xml                        |  35 +++++++++++++
 lib/Haanga/tests/assert_templates/bitwise.tpl |   2 +-
 lib/Haanga/tests/assert_templates/bug24.html  |   5 ++
 lib/Haanga/tests/assert_templates/bug24.php   |   7 +++
 lib/Haanga/tests/assert_templates/bug24.tpl   |   3 ++
 lib/Haanga/tests/assert_templates/bug25.html  |  11 +++++
 lib/Haanga/tests/assert_templates/bug25.php   |   7 +++
 lib/Haanga/tests/assert_templates/bug25.tpl   |   7 +++
 .../tests/assert_templates/bug25_class.php    |  12 +++++
 .../tests/assert_templates/explode.html       |  20 ++++++++
 lib/Haanga/tests/assert_templates/explode.php |   3 ++
 lib/Haanga/tests/assert_templates/explode.tpl |   6 +++
 lib/Haanga/tests/assert_templates/filter.html |   9 ++--
 lib/Haanga/tests/assert_templates/filter.php  |   2 +-
 lib/Haanga/tests/assert_templates/filter.tpl  |   1 +
 .../tests/assert_templates/if_else_simple.tpl |   4 +-
 .../tests/assert_templates/ifchanged.html     |   2 +-
 lib/Haanga/tests/assert_templates/load.tpl    |   2 +-
 .../locale/en/LC_MESSAGES/messages.mo         | Bin 0 -> 495 bytes
 .../locale/en/LC_MESSAGES/messages.po         |  31 ++++++++++++
 lib/Haanga/tests/assert_templates/method.html |   2 +
 lib/Haanga/tests/assert_templates/method.tpl  |   2 +
 .../tests/assert_templates/print_expr.html    |   4 ++
 .../tests/assert_templates/print_expr.php     |   3 ++
 .../tests/assert_templates/print_expr.tpl     |   4 ++
 lib/Haanga/tests/assert_templates/trans.php   |   8 +--
 lib/Haanga/tests/bootstrap.php                |  24 +++++++++
 lib/Haanga/tests/errorTest.php                |   9 ++--
 lib/Haanga/tests/templateTest.php             |  46 +++---------------
 31 files changed, 249 insertions(+), 56 deletions(-)
 create mode 100644 lib/Haanga/.travis.yml
 create mode 100644 lib/Haanga/composer.json
 create mode 100644 lib/Haanga/phpunit.xml
 create mode 100644 lib/Haanga/tests/assert_templates/bug24.html
 create mode 100644 lib/Haanga/tests/assert_templates/bug24.php
 create mode 100644 lib/Haanga/tests/assert_templates/bug24.tpl
 create mode 100644 lib/Haanga/tests/assert_templates/bug25.html
 create mode 100644 lib/Haanga/tests/assert_templates/bug25.php
 create mode 100644 lib/Haanga/tests/assert_templates/bug25.tpl
 create mode 100644 lib/Haanga/tests/assert_templates/bug25_class.php
 create mode 100644 lib/Haanga/tests/assert_templates/explode.html
 create mode 100644 lib/Haanga/tests/assert_templates/explode.php
 create mode 100644 lib/Haanga/tests/assert_templates/explode.tpl
 create mode 100644 lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.mo
 create mode 100644 lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po
 create mode 100644 lib/Haanga/tests/assert_templates/print_expr.html
 create mode 100644 lib/Haanga/tests/assert_templates/print_expr.php
 create mode 100644 lib/Haanga/tests/assert_templates/print_expr.tpl
 create mode 100644 lib/Haanga/tests/bootstrap.php

diff --git a/lib/Haanga/.travis.yml b/lib/Haanga/.travis.yml
new file mode 100644
index 00000000..ed167209
--- /dev/null
+++ b/lib/Haanga/.travis.yml
@@ -0,0 +1,15 @@
+language: php
+script: phpunit
+
+php:
+  - 5.3
+  - 5.4
+  - 5.5
+  - 5.6
+  - 7.0
+  - hhvm
+  
+before_script:
+  - curl -s http://getcomposer.org/installer | php
+  - php composer.phar install
+
diff --git a/lib/Haanga/composer.json b/lib/Haanga/composer.json
new file mode 100644
index 00000000..3eec6ed7
--- /dev/null
+++ b/lib/Haanga/composer.json
@@ -0,0 +1,19 @@
+{
+    "name": "crodas/Haanga",
+    "description": "Template compiler for PHP, Django-style (as much as possible). Pretty efficent by avoiding to have anything at run-time.",
+    "version": "v1.0.7",
+    "authors": [
+        {
+            "name": "César D. Rodas",
+            "email": "crodas@php.net"
+        }
+    ],
+    "require": {
+
+    },
+    "autoload": {
+        "classmap": [
+            "lib/"
+        ]
+    }
+}
diff --git a/lib/Haanga/phpunit.xml b/lib/Haanga/phpunit.xml
new file mode 100644
index 00000000..ca09d1aa
--- /dev/null
+++ b/lib/Haanga/phpunit.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
+<phpunit
+    backupGlobals               = "false"
+    backupStaticAttributes      = "false"
+    colors                      = "true"
+    convertErrorsToExceptions   = "true"
+    convertNoticesToExceptions  = "true"
+    convertWarningsToExceptions = "true"
+    processIsolation            = "false"
+    stopOnError                 = "true"
+    stopOnFailure               = "true"
+    stopOnIncomplete            = "true"
+    stopOnSkipped               = "ture"
+    syntaxCheck                 = "true"
+    strict                      = "false"
+    verbose                     = "true"
+    debug                       = "true"
+    bootstrap                   = "tests/bootstrap.php" >
+
+    <testsuites>
+        <testsuite name="Haanga tests">
+            <directory>tests/</directory>
+        </testsuite>
+    </testsuites>
+
+    <filter>
+        <whitelist>
+            <directory>tests/</directory>
+            <directory suffix=".php">lib/</directory>
+        </whitelist>
+    </filter>
+
+</phpunit>
diff --git a/lib/Haanga/tests/assert_templates/bitwise.tpl b/lib/Haanga/tests/assert_templates/bitwise.tpl
index bec98252..d64ae127 100644
--- a/lib/Haanga/tests/assert_templates/bitwise.tpl
+++ b/lib/Haanga/tests/assert_templates/bitwise.tpl
@@ -4,6 +4,6 @@
 {% if 13 & 2 == 0 %}
     Match
 {% endif %}
-{% if 15 | 8 == 15 %}
+{% if 15 || 8 == 15 %}
     Match
 {% endif %}
diff --git a/lib/Haanga/tests/assert_templates/bug24.html b/lib/Haanga/tests/assert_templates/bug24.html
new file mode 100644
index 00000000..b3267050
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug24.html
@@ -0,0 +1,5 @@
+
+    a
+
+    b
+
diff --git a/lib/Haanga/tests/assert_templates/bug24.php b/lib/Haanga/tests/assert_templates/bug24.php
new file mode 100644
index 00000000..c9ba9ea8
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug24.php
@@ -0,0 +1,7 @@
+<?php
+
+if (!class_exists('Obj', false)) {
+    require __DIR__ . '/bug25_class.php';
+}
+
+$data = array('obj' => new Obj);
diff --git a/lib/Haanga/tests/assert_templates/bug24.tpl b/lib/Haanga/tests/assert_templates/bug24.tpl
new file mode 100644
index 00000000..4df0e17f
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug24.tpl
@@ -0,0 +1,3 @@
+{% for a in obj.method %}
+    {{ a }}
+{% endfor %}
diff --git a/lib/Haanga/tests/assert_templates/bug25.html b/lib/Haanga/tests/assert_templates/bug25.html
new file mode 100644
index 00000000..63494e84
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25.html
@@ -0,0 +1,11 @@
+
+    a
+
+    
+
+    a
+
+    
+        test
+    
+
diff --git a/lib/Haanga/tests/assert_templates/bug25.php b/lib/Haanga/tests/assert_templates/bug25.php
new file mode 100644
index 00000000..779f690b
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25.php
@@ -0,0 +1,7 @@
+<?php
+
+if (!class_exists('Obj', false)) {
+    require __DIR__ . '/bug25_class.php';
+}
+
+$data = array('obj' => new Obj, 'base' => array('endpoint' => 'a'));
diff --git a/lib/Haanga/tests/assert_templates/bug25.tpl b/lib/Haanga/tests/assert_templates/bug25.tpl
new file mode 100644
index 00000000..06328b6f
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25.tpl
@@ -0,0 +1,7 @@
+{% for a in obj.endpoint %}
+    {{ base.endpoint }}
+
+    {% if forloop.last %}
+        test
+    {% endif %}
+{% endfor %}
diff --git a/lib/Haanga/tests/assert_templates/bug25_class.php b/lib/Haanga/tests/assert_templates/bug25_class.php
new file mode 100644
index 00000000..df02a7d3
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25_class.php
@@ -0,0 +1,12 @@
+<?php
+
+class Obj 
+{
+    public function endpoint() {
+        return $this->method();
+    }
+
+    public function method(){
+        return array('a', 'b');
+    }
+}
diff --git a/lib/Haanga/tests/assert_templates/explode.html b/lib/Haanga/tests/assert_templates/explode.html
new file mode 100644
index 00000000..29b55c51
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/explode.html
@@ -0,0 +1,20 @@
+
+    1: f
+
+    1: o
+
+    1: o
+
+    1: ,
+
+    1: b
+
+    1: a
+
+    1: r
+
+
+    w: foo
+
+    w: bar
+
diff --git a/lib/Haanga/tests/assert_templates/explode.php b/lib/Haanga/tests/assert_templates/explode.php
new file mode 100644
index 00000000..cefa262d
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/explode.php
@@ -0,0 +1,3 @@
+<?php
+
+$data  = array('text' => 'foo,bar');
diff --git a/lib/Haanga/tests/assert_templates/explode.tpl b/lib/Haanga/tests/assert_templates/explode.tpl
new file mode 100644
index 00000000..b705b5f0
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/explode.tpl
@@ -0,0 +1,6 @@
+{% for w in text|explode %}
+    1: {{ w }}
+{% endfor %}
+{% for w in text|explode:"," %}
+    w: {{ w }}
+{% endfor %}
diff --git a/lib/Haanga/tests/assert_templates/filter.html b/lib/Haanga/tests/assert_templates/filter.html
index f1acc63f..be6f0a9a 100644
--- a/lib/Haanga/tests/assert_templates/filter.html
+++ b/lib/Haanga/tests/assert_templates/filter.html
@@ -1,7 +1,8 @@
-VALUE
-value
-vale
-5
+&quot;value&quot;
+&quot;VALUE&quot;
+&quot;value&quot;
+&quot;vale&quot;
+7
 DEFAULT VALUE
 
     HOLA QUE 
diff --git a/lib/Haanga/tests/assert_templates/filter.php b/lib/Haanga/tests/assert_templates/filter.php
index 9b9169fa..0721054d 100644
--- a/lib/Haanga/tests/assert_templates/filter.php
+++ b/lib/Haanga/tests/assert_templates/filter.php
@@ -1,2 +1,2 @@
 <?php
-$data = array('var' => 'value');
+$data = array('var' => '"value"');
diff --git a/lib/Haanga/tests/assert_templates/filter.tpl b/lib/Haanga/tests/assert_templates/filter.tpl
index 9f814045..baacc2e0 100644
--- a/lib/Haanga/tests/assert_templates/filter.tpl
+++ b/lib/Haanga/tests/assert_templates/filter.tpl
@@ -1,3 +1,4 @@
+{{ var|default:"foobar" }}
 {{ var|upper }}
 {{ var|upper|lower }}
 {{ var|cut:"u" }}
diff --git a/lib/Haanga/tests/assert_templates/if_else_simple.tpl b/lib/Haanga/tests/assert_templates/if_else_simple.tpl
index aa25c0b7..b69333a8 100644
--- a/lib/Haanga/tests/assert_templates/if_else_simple.tpl
+++ b/lib/Haanga/tests/assert_templates/if_else_simple.tpl
@@ -1,6 +1,6 @@
-{% if 1 == 2 ||  1+2 == 3 %}True{% else %}False{% endif %}
+{% if 1 == 2 OR  1+2 == 3 %}True{% else %}False{% endif %}
 {% if var|upper == var %}True{% else %}False{% endif %}
-{% if 1 === 2 ||  1+2 === 3 %}True{% else %}False{% endif %}
+{% if 1 === 2 OR  1+2 === 3 %}True{% else %}False{% endif %}
 {% if 1 !== 2 %}True{% else %}False{% endif %}
 {% if 1 > 2 %}True{% else %}False{% endif %}
 {% if 1 >= 2 %}True{% else %}False{% endif %}
diff --git a/lib/Haanga/tests/assert_templates/ifchanged.html b/lib/Haanga/tests/assert_templates/ifchanged.html
index 8988c829..3a3c9065 100644
--- a/lib/Haanga/tests/assert_templates/ifchanged.html
+++ b/lib/Haanga/tests/assert_templates/ifchanged.html
@@ -17,7 +17,7 @@
     Users with 22 years
     bar
 
-    continue
+    Users with 22 years
     foo
 
     Users with 23 years
diff --git a/lib/Haanga/tests/assert_templates/load.tpl b/lib/Haanga/tests/assert_templates/load.tpl
index 664fdc12..1b77a885 100644
--- a/lib/Haanga/tests/assert_templates/load.tpl
+++ b/lib/Haanga/tests/assert_templates/load.tpl
@@ -1,4 +1,4 @@
-{% load "../contrib/meneame_pagination.php" %}
+{% load "../../contrib/meneame_pagination.php" %}
 {% meneame_pagination page results_per_page total %}
 {% if mnm_prev %}
     <span class="nextprev">&#171; Previous</span>
diff --git a/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.mo b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.mo
new file mode 100644
index 0000000000000000000000000000000000000000..a57cf97126f56a4e13a5b4aca29642d6389645ad
GIT binary patch
literal 495
zcmYk2!A`<J5QeMbrJm&MVK1J@V$lesBB9a+8(T_BA<=kQ+O^cwE^Zei2cN-{PvRqZ
z^Z~s206vAYM1qt3I@8_1v(x{(Tzb<WO27fo0(OC0K*b!`10I2W-~~|UufXY+rm2tB
z`6tw6$X}3EuOG;;v>iabtJqeLP|&={s7!hOzedv~IxMsq%QCJF1;1yJ#7>MSOcWqB
z(a`E%S$%>gBp5mVKo8iQ3yHlVNn?DmND3Ts6X`=g#9hHw{jp6YGtseO)UnaP#tEv`
z&03>kzzzs;z@Ado{7-jHtN?pHwk>q&o1Rm-@dreAX(91?Xf90D8@nzVSRO$w;#rQ{
zv1~gaqfr~Ad9t7h!y%&&CUUJof2>Asxo#&*t6U^)-E%y$`Kemf(7QaBEQdRma~M{#
zXL&TwXqum)XhucB<oP)4;pRrC47_6klRV;ankOb|PE)BXH{(SVr62DrXV*0XpH|lL
GjB39X(SpMO

literal 0
HcmV?d00001

diff --git a/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po
new file mode 100644
index 00000000..06818db4
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po
@@ -0,0 +1,31 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-07-03 16:17+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: 
+msgid "hello"
+msgstr "hola"
+
+
+#: assert_templates/trans.tpl:1 assert_templates/trans.tpl:1
+msgid "Translation"
+msgstr "Traducción"
+
+#: assert_templates/trans.tpl:2 assert_templates/trans.tpl:2
+#, c-format
+msgid "Translation by %s"
+msgstr "Traducción por %s"
diff --git a/lib/Haanga/tests/assert_templates/method.html b/lib/Haanga/tests/assert_templates/method.html
index f2e3322a..cf0aca4e 100644
--- a/lib/Haanga/tests/assert_templates/method.html
+++ b/lib/Haanga/tests/assert_templates/method.html
@@ -1,4 +1,6 @@
 foo
+foo
+FOO
 FOO
 bar
 BAR
diff --git a/lib/Haanga/tests/assert_templates/method.tpl b/lib/Haanga/tests/assert_templates/method.tpl
index b8f11730..39054f77 100644
--- a/lib/Haanga/tests/assert_templates/method.tpl
+++ b/lib/Haanga/tests/assert_templates/method.tpl
@@ -1,4 +1,6 @@
 {{ Object.method }}
+{{ Object.method() }}
 {{ Object.method|upper }}
+{{ Object.method()|upper }}
 {{ Object.bar }}
 {{ Object.bar|upper }}
diff --git a/lib/Haanga/tests/assert_templates/print_expr.html b/lib/Haanga/tests/assert_templates/print_expr.html
new file mode 100644
index 00000000..13c11b89
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/print_expr.html
@@ -0,0 +1,4 @@
+hi I'm 5 !
+Hola
+hi I'm 5 !
+hi I'm 5 !
diff --git a/lib/Haanga/tests/assert_templates/print_expr.php b/lib/Haanga/tests/assert_templates/print_expr.php
new file mode 100644
index 00000000..0f7acce4
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/print_expr.php
@@ -0,0 +1,3 @@
+<?php
+
+$data = array('b' => 3);
diff --git a/lib/Haanga/tests/assert_templates/print_expr.tpl b/lib/Haanga/tests/assert_templates/print_expr.tpl
new file mode 100644
index 00000000..f7afb9ed
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/print_expr.tpl
@@ -0,0 +1,4 @@
+hi I'm {{ 1+1+b }} !
+{{ "hola"|title}}
+hi I'm {{ 1+1+b|title }} !
+hi I'm {{ 1 > 2 ? 4 : 5 }} !
diff --git a/lib/Haanga/tests/assert_templates/trans.php b/lib/Haanga/tests/assert_templates/trans.php
index 0d95d251..3e7bd89f 100644
--- a/lib/Haanga/tests/assert_templates/trans.php
+++ b/lib/Haanga/tests/assert_templates/trans.php
@@ -5,9 +5,11 @@ if (!is_callable('bindtextdomain')) {
     throw new Exception('no gettext enabled');
 }
 
-$locale='es_ES.UTF-8';
+$locale='en_US.utf8';
 putenv("LC_ALL=$locale");
-setlocale(LC_ALL, $locale);
+if (!setlocale(LC_ALL, $locale)) {
+    throw new Exception('no gettext enabled');
+}
 
-bindtextdomain("messages", dirname(__FILE__)."/locale");
+bindtextdomain("messages", dirname(__FILE__) . "/locale");
 textdomain("messages");
diff --git a/lib/Haanga/tests/bootstrap.php b/lib/Haanga/tests/bootstrap.php
new file mode 100644
index 00000000..ab54a2a4
--- /dev/null
+++ b/lib/Haanga/tests/bootstrap.php
@@ -0,0 +1,24 @@
+<?php
+
+require __DIR__ . '/../vendor/autoload.php';
+
+$config = array(
+    'cache_dir' => __DIR__ . '/tmp/',
+    'autoload' => true,
+    'template_dir' => __DIR__,
+    'debug' => TRUE,
+    'use_hash_filename' => FALSE,
+    'compiler' => array(
+        'allow_exec' => TRUE,
+        'global' => array('test_global', 'global1'),
+    )
+);
+
+Haanga::Configure($config);
+
+date_default_timezone_set('UTC');
+
+@mkdir(__DIR__ . "/tmp/");
+foreach (glob(__DIR__ . "/tmp/*/*") as $file) {
+    @unlink($file);
+}
diff --git a/lib/Haanga/tests/errorTest.php b/lib/Haanga/tests/errorTest.php
index 939ce7d4..e74e828d 100644
--- a/lib/Haanga/tests/errorTest.php
+++ b/lib/Haanga/tests/errorTest.php
@@ -9,9 +9,8 @@ class errorTest extends PHPUnit_Framework_TestCase
      * @dataProvider tplProvider
      *  
      */
-    function testInvalidTemplates($tpl)
+    public function testInvalidTemplates($tpl)
     {
-        TestSuite::init();
         Haanga_Compiler::setOption('allow_exec', FALSE);
         try {
             Haanga::Load($tpl);
@@ -22,11 +21,11 @@ class errorTest extends PHPUnit_Framework_TestCase
         }
     }
 
-    public function tplProvider()
+    public static function tplProvider()
     {
         $datas = array();
-        foreach (glob("err_templates/*.tpl") as $err_file) {
-            $datas[] = array($err_file);
+        foreach (glob(__DIR__ . "/err_templates/*.tpl") as $err_file) {
+            $datas[] = array(substr($err_file, strlen(__DIR__)));
         }
 
         return $datas;
diff --git a/lib/Haanga/tests/templateTest.php b/lib/Haanga/tests/templateTest.php
index b6be7da5..af1fd16d 100644
--- a/lib/Haanga/tests/templateTest.php
+++ b/lib/Haanga/tests/templateTest.php
@@ -25,19 +25,10 @@ class Foo_Bar {
  */
 class templateTest extends PHPUnit_Framework_TestCase
 {
-    public function testInit()
-    {
-        /* setup */
-        @mkdir("tmp/");
-        foreach (glob("tmp/*/*") as $file) {
-            @unlink($file);
-        }
-        TestSuite::init();
-    }
-
     public function init($test_file, &$expected)
     {
-        if ($test_file == 'assert_templates/strip_whitespace.tpl') {
+        Haanga_Compiler::setOption('allow_exec', true);
+        if ($test_file === '/assert_templates/strip_whitespace.tpl') {
             Haanga_Compiler::setOption('strip_whitespace', TRUE);
             $expected = rtrim($expected). ' '; /* weird output */
         } else {
@@ -52,6 +43,7 @@ class templateTest extends PHPUnit_Framework_TestCase
         $this->init($test_file, $expected);
         $output = Haanga::Load($test_file, $data, TRUE);
         $this->assertEquals($output, $expected);
+        $this->assertTrue(filemtime(__DIR__ . $test_file) <= filemtime(__DIR__ . '/tmp/assert_templates/' . basename($test_file) . '.php'));
     }
 
     /** 
@@ -59,8 +51,9 @@ class templateTest extends PHPUnit_Framework_TestCase
      */
     public function testLambda($test_file, $data, $expected)
     {
+        chdir(dirname(__DIR__ . '/' . $test_file));
         $this->init($test_file, $expected);
-        $callback = Haanga::compile(file_get_contents($test_file), $data);
+        $callback = Haanga::compile(file_get_contents(__DIR__ . $test_file), $data);
         $output   = $callback($data);
         $this->assertEquals($output, $expected);
     }
@@ -78,37 +71,14 @@ class templateTest extends PHPUnit_Framework_TestCase
         $this->assertFalse(Haanga::$has_compiled);
     }
 
-    /** 
-     * @dataProvider tplProvider 
-     * /
-    public function testCLICompiler($test_file, $data, $expected)
-    {
-        TestSuite::init();
-        $GLOBALS['argv'][1] = $test_file;
-        $GLOBALS['argv'][2] = '--notags';
-
-        ob_start();
-        Haanga_Compiler::main_cli();
-        $code = ob_get_clean();
-
-        eval($code);
-
-        $file     = basename($test_file);
-        $pos      = strpos($file,'.');
-        $function = substr($file, 0, $pos).'_template';
-        $output   = call_user_func($function, $data, TRUE);
-
-        $this->assertEquals($output, $expected);
-    }
-    /* */
-
-    public function tplProvider()
+    public static function tplProvider()
     {
         $datas = array();
-        foreach (glob("assert_templates/*.tpl") as $test_file) {
+        foreach (glob(__DIR__  . "/assert_templates/*.tpl") as $test_file) {
             $data = array();
             $data_file = substr($test_file, 0, -3)."php";
             $expected  = substr($test_file, 0, -3)."html";
+            $test_file = substr($test_file, strlen(__DIR__));
             if (!is_file($expected)) {
                 if (!is_file($expected.".php")) {
                     continue;
-- 
GitLab