-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to ensure that post front matter can be omitted
- Loading branch information
1 parent
e0ed6f2
commit 875c6d4
Showing
1 changed file
with
44 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,44 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use Hyde\Framework\Hyde; | ||
use Illuminate\Support\Facades\Artisan; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BlogPostFrontMatterIsOptionalTest extends TestCase | ||
{ | ||
// Test blog posts can be created without having any front matter | ||
public function testBlogPostCanBeCreatedWithoutFrontMatter() | ||
{ | ||
file_put_contents(Hyde::path('_posts/test-post.md'), '# My New Post'); | ||
|
||
Artisan::call('rebuild _posts/test-post.md'); | ||
|
||
$this->assertFileExists(Hyde::path('_site/posts/test-post.html')); | ||
|
||
unlink(Hyde::path('_posts/test-post.md')); | ||
unlink(Hyde::path('_site/posts/test-post.html')); | ||
} | ||
|
||
// Test blog post feed can be rendered when having post without front matter | ||
public function testBlogPostFeedCanBeRenderedWhenPostHasNoFrontMatter() | ||
{ | ||
file_put_contents(Hyde::path('_posts/test-post.md'), '# My New Post'); | ||
|
||
// Create a temporary page to test the feed | ||
file_put_contents(Hyde::path('_pages/feed-test.blade.php'), | ||
'@foreach(Hyde::getLatestPosts() as $post) | ||
@include(\'hyde::components.article-excerpt\') | ||
@endforeach' | ||
); | ||
|
||
Artisan::call('rebuild _pages/feed-test.blade.php'); | ||
|
||
$this->assertFileExists(Hyde::path('_site/feed-test.html')); | ||
|
||
unlink(Hyde::path('_posts/test-post.md')); | ||
unlink(Hyde::path('_pages/feed-test.blade.php')); | ||
unlink(Hyde::path('_site/feed-test.html')); | ||
} | ||
} |