TwigEngineTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bridge\Twig\Tests;
  11. use Symfony\Bridge\Twig\TwigEngine;
  12. class TwigEngineTest extends TestCase
  13. {
  14. public function testExistsWithTemplateInstances()
  15. {
  16. $engine = $this->getTwig();
  17. $this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig_Template', array(), '', false)));
  18. }
  19. public function testExistsWithNonExistentTemplates()
  20. {
  21. $engine = $this->getTwig();
  22. $this->assertFalse($engine->exists('foobar'));
  23. }
  24. public function testExistsWithTemplateWithSyntaxErrors()
  25. {
  26. $engine = $this->getTwig();
  27. $this->assertTrue($engine->exists('error'));
  28. }
  29. public function testExists()
  30. {
  31. $engine = $this->getTwig();
  32. $this->assertTrue($engine->exists('index'));
  33. }
  34. protected function getTwig()
  35. {
  36. $twig = new \Twig_Environment(new \Twig_Loader_Array(array(
  37. 'index' => 'foo',
  38. 'error' => '{{ foo }',
  39. )));
  40. $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
  41. return new TwigEngine($twig, $parser);
  42. }
  43. }