diff --git a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php index 8edb4b2..b2e18d9 100644 --- a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php +++ b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php @@ -65,5 +65,21 @@ public function testInlineTemplate() { $this->assertEqual(drupal_render($element_copy), 'test-with-context muuh'); } + /** + * Tests that exceptions are thrown when a template is not found. + */ + public function testTemplateNotFoundException() { + /** @var \Drupal\Core\Template\TwigEnvironment $environment */ + $environment = \Drupal::service('twig'); + + try { + $environment->loadTemplate('this-template-does-not-exist.html.twig')->render(array()); + $this->fail('Did not throw an exception as expected.'); + } + catch (\Twig_Error_Loader $e) { + $this->assertTrue(strpos($e->getMessage(), 'Template "this-template-does-not-exist.html.twig" is not defined') === 0); + } + } + }