| 1 |
dc33f4
|
Seldaek |
<?php |
|
| 2 |
↓
|
Seldaek |
|
|
| 3 |
dd288f
|
Seldaek |
require_once DWOO_DIRECTORY . 'Dwoo/Compiler.php'; |
|
| 4 |
dc33f4
|
Seldaek |
|
|
| 5 |
↓
|
Seldaek |
class FiltersTests 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 |
// extend this class and override this in your constructor to test a modded compiler |
|
| 13 |
9cf6ad
|
Seldaek |
$this->compiler = new Dwoo_Compiler(); |
|
| 14 |
9315dc
|
seldaek |
$this->dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); |
|
| 15 |
dc33f4
|
Seldaek |
} |
|
| 16 |
↓
|
Seldaek |
|
|
| 17 |
↓
|
Seldaek |
public function testHtmlFormat() |
|
| 18 |
↓
|
Seldaek |
{ |
|
| 19 |
9cf6ad
|
Seldaek |
$tpl = new Dwoo_Template_String("<html><body><div><p>a<em>b</em>c<hr /></p><textarea>a\n b</textarea></div></body><html>"); |
|
| 20 |
dc33f4
|
Seldaek |
$tpl->forceCompilation(); |
|
| 21 |
↓
|
Seldaek |
|
|
| 22 |
9315dc
|
seldaek |
$dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); |
|
| 23 |
dc33f4
|
Seldaek |
$dwoo->addFilter('html_format', true); |
|
| 24 |
↓
|
Seldaek |
|
|
| 25 |
↓
|
Seldaek |
$this->assertEquals(str_replace("\r", '', <<<SNIPPET |
|
| 26 |
↓
|
Seldaek |
|
|
| 27 |
↓
|
Seldaek |
<html> |
|
| 28 |
↓
|
Seldaek |
<body> |
|
| 29 |
↓
|
Seldaek |
<div> |
|
| 30 |
↓
|
Seldaek |
<p> |
|
| 31 |
↓
|
Seldaek |
a<em>b</em>c |
|
| 32 |
↓
|
Seldaek |
<hr /> |
|
| 33 |
↓
|
Seldaek |
</p><textarea>a |
|
| 34 |
↓
|
Seldaek |
b</textarea> |
|
| 35 |
↓
|
Seldaek |
</div> |
|
| 36 |
↓
|
Seldaek |
</body> |
|
| 37 |
↓
|
Seldaek |
<html> |
|
| 38 |
↓
|
Seldaek |
SNIPPET |
|
| 39 |
↓
|
Seldaek |
), $dwoo->get($tpl, array(), $this->compiler)); |
|
| 40 |
↓
|
Seldaek |
} |
|
| 41 |
↓
|
Seldaek |
|
|
| 42 |
↓
|
Seldaek |
public function testSmartyCompat() |
|
| 43 |
↓
|
Seldaek |
{ |
|
| 44 |
9cf6ad
|
Seldaek |
$tpl = new Dwoo_Template_String('{ldelim}{$smarty.version}{rdelim}'); |
|
| 45 |
dc33f4
|
Seldaek |
$tpl->forceCompilation(); |
|
| 46 |
9cf6ad
|
Seldaek |
$cmp = new Dwoo_Compiler(); |
|
| 47 |
dc33f4
|
Seldaek |
$cmp->addPreProcessor('smarty_compat', true); |
|
| 48 |
↓
|
Seldaek |
|
|
| 49 |
9315dc
|
seldaek |
$this->assertEquals('{'.Dwoo_Core::VERSION.'}', $this->dwoo->get($tpl, array(), $cmp)); |
|
| 50 |
dc33f4
|
Seldaek |
} |
|
| 51 |
↓
|
Seldaek |
} |
|