Skip to content

Commit e71391f

Browse files
committed
Test all post author fields can be set in front matter
1 parent 0db6918 commit e71391f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

packages/framework/tests/Feature/PostsAuthorIntegrationTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Hyde\Framework\Testing\Feature;
66

77
use Hyde\Facades\Author;
8+
use Hyde\Pages\MarkdownPost;
89
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;
910
use Hyde\Hyde;
1011
use Hyde\Testing\TestCase;
@@ -91,6 +92,46 @@ public function testCreatePostWithDefinedAuthorWithWebsite()
9192
);
9293
}
9394

95+
public function testAllPostAuthorFieldsCanBeSetInFrontMatter()
96+
{
97+
$this->file('_posts/post-with-all-author-fields.md', <<<MD
98+
---
99+
author:
100+
username: mr_hyde
101+
name: Mr. Hyde
102+
website: https://hydephp.com
103+
bio: The mysterious author of HydePHP
104+
avatar: avatar.png
105+
socials:
106+
twitter: "@HydeFramework"
107+
github: hydephp
108+
---
109+
110+
# Post with all author fields
111+
MD
112+
);
113+
114+
$this->artisan('rebuild _posts/post-with-all-author-fields.md')->assertExitCode(0);
115+
$this->cleanUpWhenDone('_site/posts/post-with-all-author-fields.html');
116+
$this->assertFileExists(Hyde::path('_site/posts/post-with-all-author-fields.html'));
117+
118+
$page = MarkdownPost::get('post-with-all-author-fields');
119+
$this->assertNotNull($page);
120+
$this->assertNotNull($page->author);
121+
122+
$this->assertSame([
123+
'username' => 'mr_hyde',
124+
'name' => 'Mr. Hyde',
125+
'website' => 'https://hydephp.com',
126+
'bio' => 'The mysterious author of HydePHP',
127+
'avatar' => 'avatar.png',
128+
'socials' => [
129+
'twitter' => '@HydeFramework',
130+
'github' => 'hydephp',
131+
],
132+
], $page->author->toArray());
133+
}
134+
94135
protected function createPostFile(string $title, string $author): void
95136
{
96137
(new CreatesNewMarkdownPostFile($title, '', '', $author))->save();

0 commit comments

Comments
 (0)