|
5 | 5 | namespace Hyde\Framework\Testing\Feature; |
6 | 6 |
|
7 | 7 | use Hyde\Facades\Author; |
| 8 | +use Hyde\Pages\MarkdownPost; |
8 | 9 | use Hyde\Framework\Actions\CreatesNewMarkdownPostFile; |
9 | 10 | use Hyde\Hyde; |
10 | 11 | use Hyde\Testing\TestCase; |
@@ -91,6 +92,46 @@ public function testCreatePostWithDefinedAuthorWithWebsite() |
91 | 92 | ); |
92 | 93 | } |
93 | 94 |
|
| 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 | + |
94 | 135 | protected function createPostFile(string $title, string $author): void |
95 | 136 | { |
96 | 137 | (new CreatesNewMarkdownPostFile($title, '', '', $author))->save(); |
|
0 commit comments