Skip to content

Commit

Permalink
Add tests for sitemap generation
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed May 18, 2022
1 parent ce54fdc commit 4e15d0e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Feature/Commands/BuildStaticSiteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,31 @@ public function test_pretty_urls_option_output()
->assertExitCode(0);
}

public function test_sitemap_is_not_generated_when_conditions_are_not_met()
{
config(['hyde.site_url' => '']);
config(['hyde.generateSitemap' => false]);

unlinkIfExists(Hyde::path('_site/sitemap.xml'));
$this->artisan('build')
->assertExitCode(0);

$this->assertFileDoesNotExist(Hyde::path('_site/sitemap.xml'));
}

public function test_sitemap_is_generated_when_conditions_are_met()
{
config(['hyde.site_url' => 'https://example.com']);
config(['hyde.generateSitemap' => true]);

unlinkIfExists(Hyde::path('_site/sitemap.xml'));
$this->artisan('build')
->expectsOutput('Generating sitemap.xml')
->assertExitCode(0);

$this->assertFileExists(Hyde::path('_site/sitemap.xml'));
}

/**
* Added for code coverage, deprecated as the pretty flag is deprecated.
*
Expand Down

0 comments on commit 4e15d0e

Please sign in to comment.