Skip to content

Commit

Permalink
[WebBundle] added more tests to Mustache
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 6, 2010
1 parent 3bce03a commit d41e337
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Symfony/Tests/Framework/WebBundle/Util/MustacheTest.php
Expand Up @@ -12,14 +12,47 @@
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 }}!';
$expected = 'Hi {{ you }}, my name is Kris!';

$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');
}
}
@@ -0,0 +1 @@
Hello {{ me }}
@@ -0,0 +1 @@
Hello {{ me }}
@@ -0,0 +1 @@
Hello {{ me }}

0 comments on commit d41e337

Please sign in to comment.