--- /dev/null
+<?php
+
+require_once 'PHPUnit/Framework.php';
+
+class TemplateTest extends PHPUnit_Framework_TestCase
+{
+ private $fixture;
+
+ public function setUp()
+ {
+ require_once 'ISSO/App.php';
+
+ $this->fixture = BSApp::LoadModule('Template');
+ $this->fixture->setTemplateDirectory(TEST_TEMPLATE_PATH);
+ $this->fixture->setExtension('test.tpl');
+ }
+
+ public function testFetchInvalidTemplate()
+ {
+ try
+ {
+ $this->fixture->fetch('--invalid--');
+ $this->fail('exception expected');
+ }
+ catch (Exception $e)
+ {}
+ }
+
+ public function testFetch()
+ {
+ $result = $this->fixture->fetch('fetch.lang');
+ $this->assertEquals('this is a test of " . gettext(\'language\') . " strings', $result);
+
+ $result = $this->fixture->fetch('fetch.if');
+ $this->assertEquals('this " . (($a == $b) ? "is cool" : "sucks") . "!', $result);
+
+ $result = $this->fixture->fetch('fetch.php');
+ $this->assertEquals('this is " . (date(\'Y\', time()) . " today\'s year', $result);
+
+ // TODO: pass test
+ // $result = $this->fixture->fetch('fetch.php.nested');
+ // $this->assertEquals('this is a " . strpos(\'somestr{\', \'}\') . " nested token', $result);
+
+ $result = $this->fixture->fetch('fetch.lang.tag');
+ $this->assertEquals('this is a " . sprintf(\'" . gettext(\'a %1$s b %2$s\') . "\', "hello", "there") . " test', $result);
+
+ $result = $this->fixture->fetch('fetch.if.nested');
+ $this->assertEquals('this " . (($c == $d) ? "foo " . (($e == $f) ? "e" : "f") . "" : "moo " . (($g == $h) ? "g" : "h") . "") . " rules!', $result);
+
+ $result = $this->fixture->fetch('fetch.if.noelse');
+ $this->assertEquals('this is a test " . (($foo != \'moo\') ? "without else" : "") . "!', $result);
+
+ try
+ {
+ $this->fixture->fetch('fetch.lang.invalid');
+ $this->fail('exception expected');
+ }
+ catch (Exception $e)
+ {}
+
+ $result = $this->fixture->fetch('fetch.lang.indexmissing');
+ $this->assertEquals('missing " . sprintf(\'" . gettext(\'1 %1$s 2 %2$s 3 %3$s\') . "\', "a", "<strong>[MISSING SUBSTITUTION INDEX: 2]</strong>", "b") . " index', $result);
+ }
+}
+
+?>
\ No newline at end of file