✨feature: Initial MVP
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// phpcs:disable PEAR.Commenting.FileComment,PEAR.Commenting.ClassComment
|
||||
|
||||
/**
|
||||
* Front matter support tests.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use IronKanban\Support\FrontMatter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Covers front matter parsing and dumping.
|
||||
*/
|
||||
final class FrontMatterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Ensure metadata survives a dump and parse cycle.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDumpAndParseRoundTrip(): void
|
||||
{
|
||||
$meta = [
|
||||
'title' => 'Plan launch',
|
||||
'completed' => false,
|
||||
'order' => 200,
|
||||
'tags' => ['alpha', 'beta'],
|
||||
'assignee' => [
|
||||
'name' => 'Casey',
|
||||
'role' => 'owner',
|
||||
],
|
||||
];
|
||||
$body = "Ship the first milestone.\n\nKeep the checklist updated.";
|
||||
|
||||
$document = FrontMatter::parse(FrontMatter::dump($meta, $body));
|
||||
|
||||
self::assertSame($meta, $document->meta);
|
||||
self::assertSame($body . "\n", $document->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure plain markdown without front matter is preserved.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testParseWithoutFrontMatterReturnsBodyOnly(): void
|
||||
{
|
||||
$document = FrontMatter::parse("Just markdown\n\n- item");
|
||||
|
||||
self::assertSame([], $document->meta);
|
||||
self::assertSame("Just markdown\n\n- item", $document->body);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user