diff --git a/packages/framework/tests/Feature/StaticSiteBuilderDocumentationModuleTest.php b/packages/framework/tests/Feature/StaticSiteBuilderDocumentationModuleTest.php new file mode 100644 index 00000000000..82277f37e51 --- /dev/null +++ b/packages/framework/tests/Feature/StaticSiteBuilderDocumentationModuleTest.php @@ -0,0 +1,73 @@ +page = DocumentationPage::make('test-page', [ + 'title' => 'Adventures in Wonderland', + 'description' => 'All in the golden afternoon, full leisurely we glide.', + ], <<<'MARKDOWN' + ## CHAPTER I. DOWN THE RABBIT-HOLE. + + So she was considering in her own mind, as well as she could, for the hot day made her feel very sleepy and stupid. + MARKDOWN + ); + } + + protected function inspectHtml(array $expectedStrings, string $path = null) + { + StaticPageBuilder::handle($this->page); + $stream = file_get_contents(Hyde::path($path ?? '_site/docs/test-page.html')); + $this->cleanUpWhenDone($path ?? '_site/docs/test-page.html'); + + foreach ($expectedStrings as $expectedString) { + $this->assertStringContainsString($expectedString, $stream); + } + } + + public function test_can_create_page() + { + StaticPageBuilder::handle($this->page); + + $this->assertFileExists(Hyde::path('_site/docs/test-page.html')); + + unlink(Hyde::path('_site/docs/test-page.html')); + } + + public function test_page_contains_expected_content() + { + $this->inspectHtml([ + 'Adventures in Wonderland', + '

CHAPTER I. DOWN THE RABBIT-HOLE.

', + '

So she was considering in her own mind, as well as she could', + ]); + } + + public function test_can_compile_page_to_root_output_directory() + { + DocumentationPage::setOutputDirectory(''); + + $this->inspectHtml([ + 'Adventures in Wonderland', + '

CHAPTER I. DOWN THE RABBIT-HOLE.

', + '

So she was considering in her own mind, as well as she could', + ], '_site/test-page.html'); + } +}