diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index d8dc55a2826..4ed608edc70 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -4,10 +4,13 @@ namespace Hyde\Framework\Testing\Feature\Commands; +use Hyde\Pages\BladePage; use Hyde\Facades\Filesystem; use Hyde\Hyde; +use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; use Hyde\Testing\TestCase; +use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; /** * @covers \Hyde\Console\Commands\BuildSearchCommand @@ -103,4 +106,18 @@ public function test_search_files_can_be_generated_for_custom_site_and_nested_do Filesystem::deleteDirectory('foo'); } + + public function test_command_uses_page_from_kernel_when_present() + { + Hyde::pages()->addPage(tap(GeneratesDocumentationSearchIndex::makePage(), function(InMemoryPage $page): void { + $page->macro('compile', fn() => '{"foo":"bar"}'); + })); + + $this->artisan('build:search')->assertExitCode(0); + $this->assertFileExists(Hyde::path('_site/docs/search.json')); + $this->assertSame('{"foo":"bar"}', Filesystem::getContents('_site/docs/search.json')); + + Filesystem::unlink('_site/docs/search.json'); + Filesystem::unlink('_site/docs/search.html'); + } }