|
@@ -12,9 +12,27 @@
|
|
|
namespace Symfony\Tests\Framework\WebBundle\Util;
|
|
|
|
|
|
use Symfony\Framework\WebBundle\Util\Mustache;
|
|
|
+use Symfony\Framework\WebBundle\Util\Filesystem;
|
|
|
|
|
|
class MustacheTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
+ protected $dir;
|
|
|
+
|
|
|
+ public function setUp()
|
|
|
+ {
|
|
|
+ $dir = __DIR__.'/../../../../../fixtures/Symfony/Framework/WebBundle/Util';
|
|
|
+
|
|
|
+ $this->dir = sys_get_temp_dir().'/mustache';
|
|
|
+ $filesystem = new Filesystem();
|
|
|
+ $filesystem->mirror($dir, $this->dir);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function tearDown()
|
|
|
+ {
|
|
|
+ $filesystem = new Filesystem();
|
|
|
+ $filesystem->remove($this->dir);
|
|
|
+ }
|
|
|
+
|
|
|
public function testRenderString()
|
|
|
{
|
|
|
$template = 'Hi {{ you }}, my name is {{ me }}!';
|
|
@@ -22,4 +40,19 @@ class MustacheTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$this->assertEquals(Mustache::renderString($template, array('me' => 'Kris')), $expected, '::renderString() does not modify unknown parameters');
|
|
|
}
|
|
|
+
|
|
|
+ public function testRenderFile()
|
|
|
+ {
|
|
|
+ Mustache::renderFile($this->dir.'/template.txt', array('me' => 'Fabien'));
|
|
|
+
|
|
|
+ $this->assertEquals('Hello Fabien', file_get_contents($this->dir.'/template.txt'), '::renderFile() renders a file');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testRenderDir()
|
|
|
+ {
|
|
|
+ Mustache::renderDir($this->dir, array('me' => 'Fabien'));
|
|
|
+
|
|
|
+ $this->assertEquals('Hello Fabien', file_get_contents($this->dir.'/template.txt'), '::renderDir() renders a directory');
|
|
|
+ $this->assertEquals('Hello Fabien', file_get_contents($this->dir.'/foo/bar.txt'), '::renderDir() renders a directory');
|
|
|
+ }
|
|
|
}
|