🐞 fix: Linting cleanup
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// phpcs:disable
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace IronKanban\Tests;
|
||||
|
||||
use IronKanban\Markdown\FrontMatterDocument;
|
||||
use IronKanban\Markdown\FrontMatterParser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FrontMatterParserTest extends TestCase {
|
||||
public function testParsesFrontMatterAndBody(): void {
|
||||
$contents = <<<MD
|
||||
---
|
||||
id: task-123
|
||||
title: Test Task
|
||||
completed: false
|
||||
tags:
|
||||
- alpha
|
||||
- beta
|
||||
---
|
||||
|
||||
# Hello
|
||||
|
||||
This is the body.
|
||||
MD;
|
||||
|
||||
$parser = new FrontMatterParser();
|
||||
$document = $parser->parseString($contents);
|
||||
|
||||
$this->assertSame('task-123', $document->meta['id']);
|
||||
$this->assertSame('Test Task', $document->meta['title']);
|
||||
$this->assertFalse($document->meta['completed']);
|
||||
$this->assertSame(['alpha', 'beta'], $document->meta['tags']);
|
||||
$this->assertStringContainsString('# Hello', $document->body);
|
||||
}
|
||||
|
||||
public function testReturnsEmptyMetaWhenNoFrontMatterExists(): void {
|
||||
$contents = <<<MD
|
||||
# Plain Markdown
|
||||
|
||||
No front matter here.
|
||||
MD;
|
||||
|
||||
$parser = new FrontMatterParser();
|
||||
$document = $parser->parseString($contents);
|
||||
|
||||
$this->assertSame([], $document->meta);
|
||||
$this->assertStringContainsString('# Plain Markdown', $document->body);
|
||||
}
|
||||
|
||||
public function testRoundTripsUnknownMetaKeys(): void {
|
||||
$document = new FrontMatterDocument(
|
||||
meta: [
|
||||
'id' => 'task-456',
|
||||
'type' => 'task',
|
||||
'custom_key' => 'custom value',
|
||||
'nested' => [
|
||||
'one' => 'two',
|
||||
],
|
||||
],
|
||||
body: "Test body\n\nMore text."
|
||||
);
|
||||
|
||||
$parser = new FrontMatterParser();
|
||||
$dumped = $parser->dump($document);
|
||||
$parsed = $parser->parseString($dumped);
|
||||
|
||||
$this->assertSame('custom value', $parsed->meta['custom_key']);
|
||||
$this->assertSame(['one' => 'two'], $parsed->meta['nested']);
|
||||
$this->assertSame("Test body\n\nMore text.", $parsed->body);
|
||||
}
|
||||
}
|
||||
// phpcs:enable
|
||||
Reference in New Issue
Block a user