-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the test for hydephp/framework#161
- Loading branch information
1 parent
d3b8b24
commit 1a9a735
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use Hyde\Framework\Models\MarkdownDocument; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* Class HasDynamicTitleTest. | ||
* | ||
* @covers \Hyde\Framework\Models\HasDynamicTitle | ||
*/ | ||
class HasDynamicTitleTest extends TestCase | ||
{ | ||
protected array $matter; | ||
|
||
// Test it can find title from front matter. | ||
public function testFindTitleFromFrontMatter() | ||
{ | ||
$document = new MarkdownDocument([ | ||
'title' => 'My Title', | ||
], body: ''); | ||
|
||
$this->assertEquals('My Title', $document->findTitleForDocument()); | ||
} | ||
|
||
// Test it can find title from H1 tag. | ||
public function testFindTitleFromH1Tag() | ||
{ | ||
$document = new MarkdownDocument([], body: '# My Title'); | ||
|
||
$this->assertEquals('My Title', $document->findTitleForDocument()); | ||
} | ||
|
||
// Test it can find title from slug. | ||
public function testFindTitleFromSlug() | ||
{ | ||
$document = new MarkdownDocument([], body: '', slug: 'my-title'); | ||
$this->assertEquals('My Title', $document->findTitleForDocument()); | ||
} | ||
|
||
} |