12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?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');
- }
- }
|