Arbit - project tracking

Dwoo

Browse source code

File: / tests/ TemplateTests.php

Type
text/plain text/plain
Last Author
seldaek
Version
9315dcc815b5063f6212c06dd2c20b8b75004434
Line Rev. Author Source
1 5fc482 Seldaek <?php
2 Seldaek
3 dd288f Seldaek require_once DWOO_DIRECTORY . 'Dwoo/Compiler.php';
4 5fc482 Seldaek
5 Seldaek class TemplateTests extends PHPUnit_Framework_TestCase
6 Seldaek {
7 Seldaek protected $compiler;
8 Seldaek protected $dwoo;
9 Seldaek
10 Seldaek public function __construct()
11 Seldaek {
12 Seldaek $this->compiler = new Dwoo_Compiler();
13 9315dc seldaek $this->dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR);
14 5fc482 Seldaek }
15 Seldaek
16 Seldaek public function testIncludePath()
17 Seldaek {
18 Seldaek // no include path
19 Seldaek $tpl = new Dwoo_Template_File('test.html');
20 Seldaek $this->assertEquals('test.html', $tpl->getResourceIdentifier());
21 Seldaek
22 Seldaek // include path in constructor
23 Seldaek $tpl = new Dwoo_Template_File('test.html', null, null, null, TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources');
24 Seldaek $this->assertEquals(TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'test.html', $tpl->getResourceIdentifier());
25 Seldaek
26 Seldaek // set include path as string
27 Seldaek $tpl->setIncludePath(TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'subfolder'.DIRECTORY_SEPARATOR);
28 Seldaek $this->assertThat($tpl->getResourceIdentifier(), new DwooConstraintPathEquals(TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'subfolder'.DIRECTORY_SEPARATOR.'test.html'));
29 Seldaek
30 Seldaek // set include path as array
31 Seldaek $tpl->setIncludePath(array(TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'subfolder2', TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'subfolder'.DIRECTORY_SEPARATOR));
32 Seldaek $this->assertThat($tpl->getResourceIdentifier(), new DwooConstraintPathEquals(TEST_DIRECTORY.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'subfolder2'.DIRECTORY_SEPARATOR.'test.html'));
33 Seldaek }
34 Seldaek }