Add (failing) test case for disabling lambda cache.
This commit is contained in:
@@ -13,9 +13,8 @@
|
|||||||
* @group lambdas
|
* @group lambdas
|
||||||
* @group functional
|
* @group functional
|
||||||
*/
|
*/
|
||||||
class Mustache_Test_Functional_HigherOrderSectionsTest extends PHPUnit_Framework_TestCase
|
class Mustache_Test_Functional_HigherOrderSectionsTest extends Mustache_Test_FunctionalTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
private $mustache;
|
private $mustache;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
@@ -100,6 +99,49 @@ class Mustache_Test_Functional_HigherOrderSectionsTest extends PHPUnit_Framework
|
|||||||
|
|
||||||
$this->assertEquals('<em>' . $foo->name . '</em>', $tpl->render($foo));
|
$this->assertEquals('<em>' . $foo->name . '</em>', $tpl->render($foo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEnablingLambdaCacheActuallyWorks()
|
||||||
|
{
|
||||||
|
$cacheDir = $this->setUpCacheDir('test_enabling_lambda_cache');
|
||||||
|
$mustache = new Mustache_Engine(array(
|
||||||
|
'template_class_prefix' => '_TestEnablingLambdaCache_',
|
||||||
|
'cache' => $cacheDir,
|
||||||
|
'cache_lambda_templates' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
$tpl = $mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
|
||||||
|
$foo = new Mustache_Test_Functional_Foo;
|
||||||
|
$foo->wrap = array($foo, 'wrapWithEm');
|
||||||
|
$this->assertEquals('<em>' . $foo->name . '</em>', $tpl->render($foo));
|
||||||
|
$this->assertCount(2, glob($cacheDir . '/*.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisablingLambdaCacheActuallyWorks()
|
||||||
|
{
|
||||||
|
$cacheDir = $this->setUpCacheDir('test_disabling_lambda_cache');
|
||||||
|
$mustache = new Mustache_Engine(array(
|
||||||
|
'template_class_prefix' => '_TestDisablingLambdaCache_',
|
||||||
|
'cache' => $cacheDir,
|
||||||
|
'cache_lambda_templates' => false,
|
||||||
|
));
|
||||||
|
|
||||||
|
$tpl = $mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
|
||||||
|
$foo = new Mustache_Test_Functional_Foo;
|
||||||
|
$foo->wrap = array($foo, 'wrapWithEm');
|
||||||
|
$this->assertEquals('<em>' . $foo->name . '</em>', $tpl->render($foo));
|
||||||
|
$this->assertCount(1, glob($cacheDir . '/*.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setUpCacheDir($name)
|
||||||
|
{
|
||||||
|
$cacheDir = self::$tempDir . '/' . $name;
|
||||||
|
if (file_exists($cacheDir)) {
|
||||||
|
self::rmdir($cacheDir);
|
||||||
|
}
|
||||||
|
mkdir($cacheDir, 0777, true);
|
||||||
|
|
||||||
|
return $cacheDir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Mustache_Test_Functional_Foo
|
class Mustache_Test_Functional_Foo
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ abstract class Mustache_Test_FunctionalTestCase extends PHPUnit_Framework_TestCa
|
|||||||
/**
|
/**
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private static function rmdir($path)
|
protected static function rmdir($path)
|
||||||
{
|
{
|
||||||
$path = rtrim($path, '/').'/';
|
$path = rtrim($path, '/').'/';
|
||||||
$handle = opendir($path);
|
$handle = opendir($path);
|
||||||
|
|||||||
Reference in New Issue
Block a user