From 7d1573a2161762be53f6dad8edcb09aa8b85de5d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 30 Apr 2022 18:49:21 +0200 Subject: [PATCH] Update tests for full coverage --- .../HydeRebuildStaticSiteCommandTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Feature/Commands/HydeRebuildStaticSiteCommandTest.php b/tests/Feature/Commands/HydeRebuildStaticSiteCommandTest.php index 93ee800a..3963d6ec 100644 --- a/tests/Feature/Commands/HydeRebuildStaticSiteCommandTest.php +++ b/tests/Feature/Commands/HydeRebuildStaticSiteCommandTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Commands; +use Hyde\Framework\Commands\HydeRebuildStaticSiteCommand; use Hyde\Framework\Hyde; use Tests\TestCase; @@ -55,4 +56,38 @@ public function test_validate_catches_missing_file() ->expectsOutput('File [_pages/foo.md] not found.') ->assertExitCode(404); } + + public function test_rebuild_documentation_page() + { + touch(Hyde::path('_docs/foo.md')); + + $this->artisan('rebuild _docs/foo.md') + ->assertExitCode(0); + + $this->assertFileExists(Hyde::path('_site/docs/foo.html')); + + unlink(Hyde::path('_docs/foo.md')); + unlink(Hyde::path('_site/docs/foo.html')); + } + + + public function test_rebuild_blog_post() + { + // @todo replace with touch once https://github.com/hydephp/framework/issues/211 is fixed + file_put_contents(Hyde::path('_posts/foo.md'), "---\nauthor: 'foo'\n---\nfoo"); + + $this->artisan('rebuild _posts/foo.md') + ->assertExitCode(0); + + $this->assertFileExists(Hyde::path('_site/posts/foo.html')); + + unlink(Hyde::path('_posts/foo.md')); + unlink(Hyde::path('_site/posts/foo.html')); + } + + public function test_get_output_path_returns_same_input_for_out_of_bounds_page() + { + $this->assertEquals('test-page.html', + (new HydeRebuildStaticSiteCommand)->getOutputPath(('test-page.html'))); + } }