You are here

public function FrontMatterTest::testFrontMatterBroken in Drupal 9

Same name in this branch
  1. 9 core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php \Drupal\Tests\Component\FrontMatter\FrontMatterTest::testFrontMatterBroken()
  2. 9 core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php \Drupal\KernelTests\Core\Theme\FrontMatterTest::testFrontMatterBroken()

Tests broken front matter.

@covers \Drupal\Core\Template\TwigEnvironment::getTemplateMetadata @covers \Drupal\Component\FrontMatter\Exception\FrontMatterParseException

File

core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php, line 74

Class

FrontMatterTest
Tests Twig front matter support.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testFrontMatterBroken() {
  $source = "---\ncollection:\n-  key: foo\n  foo: bar\n---\n" . ComponentFrontMatterTest::SOURCE;
  $file = $this
    ->createTwigTemplate($source);
  $this
    ->expectException(SyntaxError::class);
  $this
    ->expectExceptionMessage('An error occurred when attempting to parse front matter data on line 4 in ' . $file);
  $this->twig
    ->getTemplateMetadata(basename($file));
}