diff --git a/packages/framework/tests/Feature/HydePageTest.php b/packages/framework/tests/Feature/HydePageTest.php index 43e53f63449..a620809be30 100644 --- a/packages/framework/tests/Feature/HydePageTest.php +++ b/packages/framework/tests/Feature/HydePageTest.php @@ -10,6 +10,7 @@ use Hyde\Pages\Concerns\BaseMarkdownPage; use Hyde\Pages\Concerns\HydePage; use Hyde\Pages\DocumentationPage; +use Hyde\Pages\HtmlPage; use Hyde\Pages\MarkdownPage; use Hyde\Pages\MarkdownPost; use Hyde\Support\Models\Route; @@ -122,6 +123,7 @@ public function testShowInNavigation() $this->assertTrue((new MarkdownPage())->showInNavigation()); $this->assertTrue((new DocumentationPage())->showInNavigation()); $this->assertFalse((new MarkdownPost())->showInNavigation()); + $this->assertTrue((new HtmlPage())->showInNavigation()); } public function testNavigationMenuPriority() @@ -130,6 +132,7 @@ public function testNavigationMenuPriority() $this->assertSame(999, (new MarkdownPage())->navigationMenuPriority()); $this->assertSame(999, (new DocumentationPage())->navigationMenuPriority()); $this->assertSame(10, (new MarkdownPost())->navigationMenuPriority()); + $this->assertSame(999, (new HtmlPage())->navigationMenuPriority()); } public function testNavigationMenuLabel() @@ -138,6 +141,7 @@ public function testNavigationMenuLabel() $this->assertSame('Foo', (new MarkdownPage('foo'))->navigationMenuLabel()); $this->assertSame('Foo', (new MarkdownPost('foo'))->navigationMenuLabel()); $this->assertSame('Foo', (new DocumentationPage('foo'))->navigationMenuLabel()); + $this->assertSame('Foo', (new HtmlPage('foo'))->navigationMenuLabel()); } public function testNavigationMenuGroup() @@ -145,6 +149,7 @@ public function testNavigationMenuGroup() $this->assertNull((new BladePage('foo'))->navigationMenuGroup()); $this->assertNull((new MarkdownPage())->navigationMenuGroup()); $this->assertNull((new MarkdownPost())->navigationMenuGroup()); + $this->assertNull((new HtmlPage())->navigationMenuGroup()); $this->assertSame('other', (new DocumentationPage())->navigationMenuGroup()); $this->assertSame('foo', DocumentationPage::make(matter: ['navigation' => ['group' => 'foo']])->navigationMenuGroup()); } @@ -870,6 +875,34 @@ public function test_path_helpers_return_same_result_as_fluent_filesystem_helper $this->assertSameIgnoringDirSeparatorType(DocumentationPage::path('foo'), Hyde::getDocumentationPagePath('foo')); } + public function test_all_pages_are_routable() + { + $pages = [ + BladePage::class, + MarkdownPage::class, + MarkdownPost::class, + DocumentationPage::class, + HtmlPage::class, + ]; + + /** @var HydePage $page */ + foreach ($pages as $page) { + $page = new $page('foo'); + + $this->assertInstanceOf(Route::class, $page->getRoute()); + $this->assertEquals(new Route($page), $page->getRoute()); + $this->assertSame($page->getRoute()->getLink(), $page->getLink()); + + Hyde::touch($page::sourcePath('foo')); + Hyde::boot(); + + $this->assertArrayHasKey($page->getSourcePath(), Hyde::pages()); + $this->assertArrayHasKey($page->getRouteKey(), Hyde::routes()); + + unlink($page::sourcePath('foo')); + } + } + protected function assertSameIgnoringDirSeparatorType(string $expected, string $actual): void { $this->assertSame( diff --git a/packages/framework/tests/Feature/Services/SitemapServiceTest.php b/packages/framework/tests/Feature/Services/SitemapServiceTest.php index e4acad13d47..bd47835b3ae 100644 --- a/packages/framework/tests/Feature/Services/SitemapServiceTest.php +++ b/packages/framework/tests/Feature/Services/SitemapServiceTest.php @@ -134,6 +134,7 @@ public function test_all_route_types_are_discovered() $files = [ '_pages/blade.blade.php', '_pages/markdown.md', + '_pages/html.html', '_posts/post.md', '_docs/doc.md', ]; @@ -143,12 +144,13 @@ public function test_all_route_types_are_discovered() $service = new SitemapGenerator(); $service->generate(); - $this->assertCount(4, $service->getXmlElement()->url); + $this->assertCount(5, $service->getXmlElement()->url); - $this->assertEquals('foo/blade.html', $service->getXmlElement()->url[0]->loc); - $this->assertEquals('foo/markdown.html', $service->getXmlElement()->url[1]->loc); - $this->assertEquals('foo/posts/post.html', $service->getXmlElement()->url[2]->loc); - $this->assertEquals('foo/docs/doc.html', $service->getXmlElement()->url[3]->loc); + $this->assertEquals('foo/html.html', $service->getXmlElement()->url[0]->loc); + $this->assertEquals('foo/blade.html', $service->getXmlElement()->url[1]->loc); + $this->assertEquals('foo/markdown.html', $service->getXmlElement()->url[2]->loc); + $this->assertEquals('foo/posts/post.html', $service->getXmlElement()->url[3]->loc); + $this->assertEquals('foo/docs/doc.html', $service->getXmlElement()->url[4]->loc); Hyde::unlink($files); diff --git a/packages/framework/tests/Feature/HtmlPageTest.php b/packages/framework/tests/Unit/HtmlPageTest.php similarity index 73% rename from packages/framework/tests/Feature/HtmlPageTest.php rename to packages/framework/tests/Unit/HtmlPageTest.php index 5d9752f4fa8..7e51c645577 100644 --- a/packages/framework/tests/Feature/HtmlPageTest.php +++ b/packages/framework/tests/Unit/HtmlPageTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hyde\Framework\Testing\Feature; +namespace Hyde\Framework\Testing\Unit; use Hyde\Pages\HtmlPage; use Hyde\Testing\TestCase; @@ -14,7 +14,7 @@ class HtmlPageTest extends TestCase { public function testHtmlPageCanBeCompiled() { - $this->file(HtmlPage::$sourceDirectory.'/foo.html', 'bar'); + $this->file('_pages/foo.html', 'bar'); $page = new HtmlPage('foo'); @@ -23,7 +23,7 @@ public function testHtmlPageCanBeCompiled() public function testCompileMethodUsesContents() { - $this->file(HtmlPage::$sourceDirectory.'/foo.html', 'bar'); + $this->file('_pages/foo.html', 'bar'); $page = new HtmlPage('foo');