This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Framework/WebBundle/Util/MustacheTest.php
2010-05-06 13:25:53 +02:00

59 lines
1.8 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
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');
}
}