Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Update tests to cover missing code coverage lines #1761

Merged
merged 11 commits into from
Jun 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ abstract class PageDataFactory implements Arrayable
* Get the generated data as an associative array.
*
* @return array<string, mixed>
*
* @codeCoverageIgnore
*/
abstract public function toArray(): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class BuildSitemapCommandTest extends TestCase
public function testSitemapIsGeneratedWhenConditionsAreMet()
{
$this->withSiteUrl();
config(['hyde.generate_sitemap' => true]);

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

Expand All @@ -26,4 +25,19 @@ public function testSitemapIsGeneratedWhenConditionsAreMet()

Filesystem::unlink('_site/sitemap.xml');
}

public function testSitemapIsNotGeneratedWhenConditionsAreNotMet()
{
$this->withoutSiteUrl();

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

$this->artisan('build:sitemap')
->expectsOutputToContain('Generating sitemap...')
->expectsOutputToContain('Skipped')
->expectsOutput(' > Cannot generate sitemap without a valid base URL')
->assertExitCode(0);

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