From 19bfa2ed8c4c216ed827670ed53e1aa408a3a00d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 27 Jan 2016 18:13:21 +0100 Subject: [PATCH] Added a test --- .../Tests/Loader/FilesystemLoaderTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index 3fd0888cda..cc993c7527 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -98,4 +98,21 @@ class FilesystemLoaderTest extends TestCase $loader = new FilesystemLoader($locator, $parser); $loader->getCacheKey('name.format.engine'); } + + /** + * @expectedException \Twig_Error_Loader + * @expectedExceptionMessageRegExp /Unable to find template "name\.format\.engine" \(looked into: .*\/Tests\/Loader\/\.\.\/DependencyInjection\/Fixtures\/Resources\/views\)/ + */ + public function testTwigErrorIfTemplateDoesNotExist() + { + $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); + $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + + $loader = new FilesystemLoader($locator, $parser); + $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); + + $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method->setAccessible(true); + $method->invoke($loader, 'name.format.engine'); + } }