function FrontMatterTest::testFrontMatterBroken

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php \Drupal\KernelTests\Core\Theme\FrontMatterTest::testFrontMatterBroken()
Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php \Drupal\KernelTests\Core\Theme\FrontMatterTest::testFrontMatterBroken()
  2. 9 core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php \Drupal\Tests\Component\FrontMatter\FrontMatterTest::testFrontMatterBroken()
  3. 11.x core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php \Drupal\KernelTests\Core\Theme\FrontMatterTest::testFrontMatterBroken()
  4. 11.x core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php \Drupal\Tests\Component\FrontMatter\FrontMatterTest::testFrontMatterBroken()

Tests broken front matter.

@covers ::__construct @covers ::create @covers ::parse @covers \Drupal\Component\FrontMatter\Exception\FrontMatterParseException

File

core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php, line 67

Class

FrontMatterTest
Tests front matter parsing helper methods.

Namespace

Drupal\Tests\Component\FrontMatter

Code

public function testFrontMatterBroken() : void {
    $this->expectException(FrontMatterParseException::class);
    $this->expectExceptionMessage('An error occurred when attempting to parse front matter data on line 4');
    $source = "---\ncollection:\n-  key: foo\n  foo: bar\n---\n";
    FrontMatter::create($source)->getData();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.