Skip to content

Commit

Permalink
Merge unit test into feature test
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Sep 9, 2024
1 parent c03b9eb commit 36e2413
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 45 deletions.
34 changes: 34 additions & 0 deletions packages/framework/tests/Feature/MarkdownPostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Hyde\Framework\Testing\Feature;

use Hyde\Hyde;
use Hyde\Pages\BladePage;
use Hyde\Facades\Filesystem;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
use Hyde\Framework\Features\Blogging\Models\PostAuthor;
use Hyde\Markdown\Models\FrontMatter;
Expand Down Expand Up @@ -107,4 +111,34 @@ public function testFeaturedImageCanBeConstructedReturnsImageObjectWithSuppliedD
$this->assertSame('media/foo.png', $image->getSource());
$this->assertSame('bar', $image->getTitleText());
}

public function testBlogPostCanBeCreatedWithoutFrontMatter()
{
file_put_contents(Hyde::path('_posts/test-post.md'), '# My New Post');

StaticPageBuilder::handle(MarkdownPost::get('test-post'));

$this->assertFileExists(Hyde::path('_site/posts/test-post.html'));

Filesystem::unlink('_posts/test-post.md');
Filesystem::unlink('_site/posts/test-post.html');
}

public function testBlogPostFeedCanBeRenderedWhenPostHasNoFrontMatter()
{
file_put_contents(Hyde::path('_posts/test-post.md'), '# My New Post');

// Create a temporary page to test the feed
copy(Hyde::vendorPath('resources/views/components/blog-post-feed.blade.php'),
Hyde::path('_pages/feed-test.blade.php')
);

StaticPageBuilder::handle(BladePage::get('feed-test'));

$this->assertFileExists(Hyde::path('_site/feed-test.html'));

Filesystem::unlink('_posts/test-post.md');
Filesystem::unlink('_pages/feed-test.blade.php');
Filesystem::unlink('_site/feed-test.html');
}
}

This file was deleted.

0 comments on commit 36e2413

Please sign in to comment.