Skip to content

Commit

Permalink
Add the test for hydephp/framework#161
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 21, 2022
1 parent d3b8b24 commit 1a9a735
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/Unit/HasDynamicTitleTest.php
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());
}

}

0 comments on commit 1a9a735

Please sign in to comment.