Skip to content

Commit 1a9a735

Browse files
committed
Add the test for hydephp/framework#161
1 parent d3b8b24 commit 1a9a735

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/Unit/HasDynamicTitleTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Tests\Unit;
4+
5+
use Hyde\Framework\Models\MarkdownDocument;
6+
use Tests\TestCase;
7+
8+
/**
9+
* Class HasDynamicTitleTest.
10+
*
11+
* @covers \Hyde\Framework\Models\HasDynamicTitle
12+
*/
13+
class HasDynamicTitleTest extends TestCase
14+
{
15+
protected array $matter;
16+
17+
// Test it can find title from front matter.
18+
public function testFindTitleFromFrontMatter()
19+
{
20+
$document = new MarkdownDocument([
21+
'title' => 'My Title',
22+
], body: '');
23+
24+
$this->assertEquals('My Title', $document->findTitleForDocument());
25+
}
26+
27+
// Test it can find title from H1 tag.
28+
public function testFindTitleFromH1Tag()
29+
{
30+
$document = new MarkdownDocument([], body: '# My Title');
31+
32+
$this->assertEquals('My Title', $document->findTitleForDocument());
33+
}
34+
35+
// Test it can find title from slug.
36+
public function testFindTitleFromSlug()
37+
{
38+
$document = new MarkdownDocument([], body: '', slug: 'my-title');
39+
$this->assertEquals('My Title', $document->findTitleForDocument());
40+
}
41+
42+
}

0 commit comments

Comments
 (0)