Skip to content

Commit

Permalink
Update tests for full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 30, 2022
1 parent 427947d commit 7d1573a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Feature/Commands/HydeRebuildStaticSiteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Feature\Commands;

use Hyde\Framework\Commands\HydeRebuildStaticSiteCommand;
use Hyde\Framework\Hyde;
use Tests\TestCase;

Expand Down Expand Up @@ -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')));
}
}

0 comments on commit 7d1573a

Please sign in to comment.