3 require_once 'PHPUnit/Framework.php';
5 class TemplateTest
extends PHPUnit_Framework_TestCase
9 public function setUp()
11 require_once 'ISSO/App.php';
13 $this->fixture
= BSApp
::LoadModule('Template');
14 $this->fixture
->setTemplateDirectory(TEST_TEMPLATE_PATH
);
15 $this->fixture
->setExtension('test.tpl');
18 public function testFetchInvalidTemplate()
22 $this->fixture
->fetch('--invalid--');
23 $this->fail('exception expected');
29 public function testFetch()
31 $result = $this->fixture
->fetch('fetch.lang');
32 $this->assertEquals('this is a test of " . gettext(\'language\') . " strings', $result);
34 $result = $this->fixture
->fetch('fetch.if');
35 $this->assertEquals('this " . (($a == $b) ? "is cool" : "sucks") . "!', $result);
37 $result = $this->fixture
->fetch('fetch.php');
38 $this->assertEquals('this is " . (date(\'Y\', time()) . " today\'s year', $result);
41 // $result = $this->fixture->fetch('fetch.php.nested');
42 // $this->assertEquals('this is a " . strpos(\'somestr{\', \'}\') . " nested token', $result);
44 $result = $this->fixture
->fetch('fetch.lang.tag');
45 $this->assertEquals('this is a " . sprintf(\'" . gettext(\'a %1$s b %2$s\') . "\', "hello", "there") . " test', $result);
47 $result = $this->fixture
->fetch('fetch.if.nested');
48 $this->assertEquals('this " . (($c == $d) ? "foo " . (($e == $f) ? "e" : "f") . "" : "moo " . (($g == $h) ? "g" : "h") . "") . " rules!', $result);
50 $result = $this->fixture
->fetch('fetch.if.noelse');
51 $this->assertEquals('this is a test " . (($foo != \'moo\') ? "without else" : "") . "!', $result);
55 $this->fixture
->fetch('fetch.lang.invalid');
56 $this->fail('exception expected');
61 $result = $this->fixture
->fetch('fetch.lang.indexmissing');
62 $this->assertEquals('missing " . sprintf(\'" . gettext(\'1 %1$s 2 %2$s 3 %3$s\') . "\', "a", "<strong>[MISSING SUBSTITUTION INDEX: 2]</strong>", "b") . " index', $result);