PEAR2_Templates_Savant-0.2.0 › PEAR2_Templates_Savant-0.2.0/test/PEAR2_Templates_Savant/pear2.php.net/render/fastcompile.phpt
- PEAR2_Templates_Savant-0.2.0/
- doc/
- PEAR2_Templates_Savant/
- pear2.php.net/
- examples/
- baseball/
- examples/
- templates/
- examples/
- examples/
- pear2.php.net/
- PEAR2_Templates_Savant/
- php/
- PEAR2/
- Autoload.php
- Exception.php
- MultiErrors/
- MultiErrors.php
- Templates/
- PEAR2/
- test/
- PEAR2_Templates_Savant/
- doc/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
\PEAR2\Templates\Savant\Main::render() fast compiler test
--FILE--
<?php
require dirname(__FILE__) . '/../test_framework.php.inc';
chdir(__DIR__);
$savant = new \PEAR2\Templates\Savant\Main();
class Foo
{
public $var1;
function __toString()
{
return 'test';
}
}
$object = new Foo();
$object->var1 = ' is my class';
$savant->setEscape();
mkdir(__DIR__ . '/compiled');
$compiler = new PEAR2\Templates\Savant\BasicFastCompiler(__DIR__ . DIRECTORY_SEPARATOR . 'compiled');
$savant->setCompiler($compiler);
$test->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR .
md5('.' . DIRECTORY_SEPARATOR . 'Foo.tpl.php'), $savant->template('Foo.tpl.php'),
'verify compiler is called');
$test->assertEquals("<?php return '' . get_class(\$context) . '
' . \$context->var1 . '';", file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR .
md5('.' . DIRECTORY_SEPARATOR . 'Foo.tpl.php')), 'compiled template');
$test->assertEquals('Foo is my class', $savant->render($object), 'render object');
$test->assertEquals('test', $savant->render($object, 'echostring.tpl.php'), 'render object with custom template');
?>
===DONE===
--CLEAN--
<?php
$a = opendir(__DIR__ . '/compiled');
while (false !== ($b = readdir($a))) {
if (is_dir(__DIR__ . '/compiled/' . $b)) continue;
unlink(__DIR__ . '/compiled/' . $b);
}
rmdir(__DIR__ . '/compiled');
?>
--EXPECT--
===DONE===EOF
