public function FrontMatterTest::testFrontMatterData in Drupal 9
Tests the parsed data from front matter.
@covers ::__construct @covers ::getContent @covers ::getData @covers ::getLine @covers ::create @covers ::parse
@dataProvider providerFrontMatterData
Parameters
array|null $yaml: The YAML used as front matter data to prepend the source.
int $line: The expected line number where the source code starts.
string $content: The content to use for testing purposes.
File
- core/
tests/ Drupal/ Tests/ Component/ FrontMatter/ FrontMatterTest.php, line 91
Class
- FrontMatterTest
- Tests front matter parsing helper methods.
Namespace
Drupal\Tests\Component\FrontMatterCode
public function testFrontMatterData($yaml, $line, $content = self::SOURCE) {
$source = static::createFrontMatterSource($yaml, $content);
$frontMatter = FrontMatter::create($source);
$this
->assertEquals($content, $frontMatter
->getContent());
$this
->assertEquals($yaml === NULL ? [] : $yaml, $frontMatter
->getData());
$this
->assertEquals($line, $frontMatter
->getLine());
}