Skip to content

Commit

Permalink
Clean up and improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Oct 6, 2024
1 parent 269f0fb commit c936cbe
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions packages/framework/tests/Feature/StaticSiteServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,41 @@ public function testBuildCommandCreatesHtmlFiles()

public function testBuildCommandTransfersMediaAssetFiles()
{
file_put_contents(Hyde::path('_media/test-image.png'), 'foo');
$this->artisan('build');
$this->file('_media/test-image.png', 'foo');
$this->artisan('build')
->expectsOutputToContain('Transferring Media Assets...');

$this->assertFileEquals(Hyde::path('_media/test-image.png'), Hyde::path('_site/media/test-image.png'));
Filesystem::unlink('_media/test-image.png');

Filesystem::unlink('_site/media/test-image.png');
}

public function testBuildCommandTransfersMediaAssetFilesRecursively()
{
$this->directory('_media/foo');

file_put_contents(Hyde::path('_media/foo/img.png'), 'foo');
$this->file('_media/foo/img.png', 'foo');
$this->artisan('build')->assertSuccessful();
$this->assertFileEquals(Hyde::path('_media/foo/img.png'), Hyde::path('_site/media/foo/img.png'));
}

public function testBuildCommandCreatesNeededDirectoriesRecursively()
{
$this->directory('_media/foo/bar');
$this->file('_media/1.png');
$this->file('_media/foo/2.png');
$this->file('_media/foo/bar/3.png');

Filesystem::deleteDirectory('_site');

$this->artisan('build')
->assertExitCode(0);

$this->assertFileExists(Hyde::path('_site/media/1.png'));
$this->assertFileExists(Hyde::path('_site/media/foo/2.png'));
$this->assertFileExists(Hyde::path('_site/media/foo/bar/3.png'));
}

public function testAllPageTypesCanBeCompiled()
{
$this->file('_pages/html.html');
Expand All @@ -96,12 +115,6 @@ public function testAllPageTypesCanBeCompiled()
$this->assertFileExists(Hyde::path('_site/markdown.html'));
$this->assertFileExists(Hyde::path('_site/posts/post.html'));
$this->assertFileExists(Hyde::path('_site/docs/docs.html'));

Filesystem::unlink('_site/html.html');
Filesystem::unlink('_site/blade.html');
Filesystem::unlink('_site/markdown.html');
Filesystem::unlink('_site/posts/post.html');
Filesystem::unlink('_site/docs/docs.html');
}

public function testOnlyProgressBarsForTypesWithPagesAreShown()
Expand All @@ -120,8 +133,6 @@ public function testOnlyProgressBarsForTypesWithPagesAreShown()

$this->assertFileExists(Hyde::path('_site/blade.html'));
$this->assertFileExists(Hyde::path('_site/markdown.html'));
Filesystem::unlink('_site/blade.html');
Filesystem::unlink('_site/markdown.html');
}

public function testPrintInitialInformationAllowsApiToBeDisabled()
Expand Down

0 comments on commit c936cbe

Please sign in to comment.