| 1 |
b5cb46
|
Seldaek |
<?php |
|
| 2 |
↓
|
Seldaek |
|
|
| 3 |
dd288f
|
Seldaek |
require_once DWOO_DIRECTORY . 'Dwoo/Compiler.php'; |
|
| 4 |
b5cb46
|
Seldaek |
|
|
| 5 |
↓
|
Seldaek |
class LoaderTests 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 |
↓
|
Seldaek |
$this->compiler = new Dwoo_Compiler(); |
|
| 14 |
9315dc
|
seldaek |
$this->dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); |
|
| 15 |
b5cb46
|
Seldaek |
} |
|
| 16 |
↓
|
Seldaek |
|
|
| 17 |
↓
|
Seldaek |
public function testLoaderGetSet() |
|
| 18 |
↓
|
Seldaek |
{ |
|
| 19 |
9315dc
|
seldaek |
$dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); |
|
| 20 |
b5cb46
|
Seldaek |
$loader = new Dwoo_Loader(TEST_DIRECTORY.'/temp/cache'); |
|
| 21 |
↓
|
Seldaek |
|
|
| 22 |
↓
|
Seldaek |
$dwoo->setLoader($loader); |
|
| 23 |
↓
|
Seldaek |
$this->assertEquals($loader, $dwoo->getLoader()); |
|
| 24 |
↓
|
Seldaek |
} |
|
| 25 |
↓
|
Seldaek |
|
|
| 26 |
↓
|
Seldaek |
public function testPluginLoad() |
|
| 27 |
↓
|
Seldaek |
{ |
|
| 28 |
9315dc
|
seldaek |
$dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); |
|
| 29 |
b5cb46
|
Seldaek |
$loader = new Dwoo_Loader(TEST_DIRECTORY.'/temp/cache'); |
|
| 30 |
↓
|
Seldaek |
|
|
| 31 |
↓
|
Seldaek |
$dwoo->setLoader($loader); |
|
| 32 |
↓
|
Seldaek |
$loader->addDirectory(TEST_DIRECTORY.'/resources/plugins'); |
|
| 33 |
↓
|
Seldaek |
|
|
| 34 |
↓
|
Seldaek |
$tpl = new Dwoo_Template_String('{loaderTest}'); |
|
| 35 |
↓
|
Seldaek |
$tpl->forceCompilation(); |
|
| 36 |
↓
|
Seldaek |
$this->assertEquals('Moo', $dwoo->get($tpl, array(), $this->compiler)); |
|
| 37 |
↓
|
Seldaek |
} |
|
| 38 |
↓
|
Seldaek |
|
|
| 39 |
↓
|
Seldaek |
public function testRebuildClassPath() |
|
| 40 |
↓
|
Seldaek |
{ |
|
| 41 |
9315dc
|
seldaek |
$dwoo = new Dwoo_Core(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); |
|
| 42 |
b5cb46
|
Seldaek |
$loader = new Dwoo_Loader(TEST_DIRECTORY.'/temp/cache'); |
|
| 43 |
↓
|
Seldaek |
|
|
| 44 |
↓
|
Seldaek |
$dwoo->setLoader($loader); |
|
| 45 |
↓
|
Seldaek |
$loader->addDirectory(TEST_DIRECTORY.'/resources/plugins'); |
|
| 46 |
9315dc
|
seldaek |
file_put_contents(TEST_DIRECTORY.'/resources/plugins/loaderTest2.php', '<?php function Dwoo_Plugin_loaderTest2(Dwoo_Core $dwoo) { return "It works!"; }'); |
|
| 47 |
b5cb46
|
Seldaek |
|
|
| 48 |
↓
|
Seldaek |
$tpl = new Dwoo_Template_String('{loaderTest2}'); |
|
| 49 |
↓
|
Seldaek |
$tpl->forceCompilation(); |
|
| 50 |
↓
|
Seldaek |
$this->assertEquals('It works!', $dwoo->get($tpl, array(), $this->compiler)); |
|
| 51 |
↓
|
Seldaek |
unlink(TEST_DIRECTORY.'/resources/plugins/loaderTest2.php'); |
|
| 52 |
↓
|
Seldaek |
} |
|
| 53 |
↓
|
Seldaek |
} |
|