diff --git a/packages/framework/tests/Unit/Pages/PageModelGetAllFilesHelperTest.php b/packages/framework/tests/Unit/Pages/PageModelGetAllFilesHelperTest.php deleted file mode 100644 index 68257f0e847..00000000000 --- a/packages/framework/tests/Unit/Pages/PageModelGetAllFilesHelperTest.php +++ /dev/null @@ -1,74 +0,0 @@ -cleanupFilesystem(); - } - - public function testBladePageGetHelperReturnsBladePageArray() - { - $this->files(['_pages/test-page.blade.php']); - - HydeKernel::getInstance()->boot(); - - $array = BladePage::files(); - $this->assertCount(3, $array); - $this->assertIsArray($array); - $this->assertEquals(['404', 'index', 'test-page'], $array); - } - - public function testMarkdownPageGetHelperReturnsMarkdownPageArray() - { - $this->files(['_pages/test-page.md']); - - HydeKernel::getInstance()->boot(); - - $array = MarkdownPage::files(); - $this->assertCount(1, $array); - $this->assertIsArray($array); - $this->assertEquals(['test-page'], $array); - } - - public function testMarkdownPostGetHelperReturnsMarkdownPostArray() - { - $this->files(['_posts/test-post.md']); - - HydeKernel::getInstance()->boot(); - - $array = MarkdownPost::files(); - $this->assertCount(1, $array); - $this->assertIsArray($array); - $this->assertEquals(['test-post'], $array); - } - - public function testDocumentationPageGetHelperReturnsDocumentationPageArray() - { - $this->files(['_docs/test-page.md']); - - HydeKernel::getInstance()->boot(); - - $array = DocumentationPage::files(); - $this->assertCount(1, $array); - $this->assertIsArray($array); - $this->assertEquals(['test-page'], $array); - } -} diff --git a/packages/framework/tests/Unit/Pages/PageModelGetFileHelpersTest.php b/packages/framework/tests/Unit/Pages/PageModelGetFileHelpersTest.php new file mode 100644 index 00000000000..0586b3110d3 --- /dev/null +++ b/packages/framework/tests/Unit/Pages/PageModelGetFileHelpersTest.php @@ -0,0 +1,115 @@ +withFile('_pages/test-page.blade.php'); + + $array = BladePage::files(); + $this->assertCount(3, $array); + $this->assertIsArray($array); + $this->assertEquals(['404', 'index', 'test-page'], $array); + } + + public function testMarkdownPageFilesHelperReturnsMarkdownPageArray() + { + $this->withFile('_pages/test-page.md'); + + $array = MarkdownPage::files(); + $this->assertCount(1, $array); + $this->assertIsArray($array); + $this->assertEquals(['test-page'], $array); + } + + public function testMarkdownPostFilesHelperReturnsMarkdownPostArray() + { + $this->withFile('_posts/test-post.md'); + + $array = MarkdownPost::files(); + $this->assertCount(1, $array); + $this->assertIsArray($array); + $this->assertEquals(['test-post'], $array); + } + + public function testDocumentationPageFilesHelperReturnsDocumentationPageArray() + { + $this->withFile('_docs/test-page.md'); + + $array = DocumentationPage::files(); + $this->assertCount(1, $array); + $this->assertIsArray($array); + $this->assertEquals(['test-page'], $array); + } + + public function testBladePageAllHelperReturnsBladePageCollection() + { + $this->withFile('_pages/test-page.blade.php'); + + $collection = BladePage::all(); + + $this->assertCount(3, $collection); + $this->assertInstanceOf(Collection::class, $collection); + $this->assertContainsOnlyInstancesOf(BladePage::class, $collection); + } + + public function testMarkdownPageAllHelperReturnsMarkdownPageCollection() + { + $this->withFile('_pages/test-page.md'); + + $collection = MarkdownPage::all(); + $this->assertCount(1, $collection); + $this->assertInstanceOf(Collection::class, $collection); + $this->assertContainsOnlyInstancesOf(MarkdownPage::class, $collection); + } + + public function testMarkdownPostAllHelperReturnsMarkdownPostCollection() + { + $this->withFile('_posts/test-post.md'); + + $collection = MarkdownPost::all(); + $this->assertCount(1, $collection); + $this->assertInstanceOf(Collection::class, $collection); + $this->assertContainsOnlyInstancesOf(MarkdownPost::class, $collection); + } + + public function testDocumentationPageAllHelperReturnsDocumentationPageCollection() + { + $this->withFile('_docs/test-page.md'); + + $collection = DocumentationPage::all(); + $this->assertCount(1, $collection); + $this->assertInstanceOf(Collection::class, $collection); + $this->assertContainsOnlyInstancesOf(DocumentationPage::class, $collection); + } + + protected function withFile(string $path): void + { + $this->file($path); + + HydeKernel::getInstance()->boot(); + } + + protected function tearDown(): void + { + $this->cleanupFilesystem(); + } +} diff --git a/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php b/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php deleted file mode 100644 index cf6232c2d1e..00000000000 --- a/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php +++ /dev/null @@ -1,97 +0,0 @@ -filesystem = $this->mockFilesystemStrict() - ->shouldReceive('glob')->once()->with(Hyde::path('_pages/{*,**/*}.html'), GLOB_BRACE)->andReturn([])->byDefault() - ->shouldReceive('glob')->once()->with(Hyde::path('_pages/{*,**/*}.blade.php'), GLOB_BRACE)->andReturn([])->byDefault() - ->shouldReceive('glob')->once()->with(Hyde::path('_pages/{*,**/*}.md'), GLOB_BRACE)->andReturn([])->byDefault() - ->shouldReceive('glob')->once()->with(Hyde::path('_posts/{*,**/*}.md'), GLOB_BRACE)->andReturn([])->byDefault() - ->shouldReceive('glob')->once()->with(Hyde::path('_docs/{*,**/*}.md'), GLOB_BRACE)->andReturn([])->byDefault(); - } - - protected function tearDown(): void - { - $this->verifyMockeryExpectations(); - } - - public function testBladePageGetHelperReturnsBladePageCollection() - { - $this->shouldReceiveGlob('_pages/{*,**/*}.blade.php')->andReturn(['_pages/test-page.blade.php']); - $this->shouldFindFile('_pages/test-page.blade.php'); - - $collection = BladePage::all(); - $this->assertCount(1, $collection); - $this->assertInstanceOf(Collection::class, $collection); - $this->assertContainsOnlyInstancesOf(BladePage::class, $collection); - } - - public function testMarkdownPageGetHelperReturnsMarkdownPageCollection() - { - $this->shouldReceiveGlob('_pages/{*,**/*}.md')->andReturn(['_pages/test-page.md']); - $this->shouldFindFile('_pages/test-page.md'); - - $collection = MarkdownPage::all(); - $this->assertCount(1, $collection); - $this->assertInstanceOf(Collection::class, $collection); - $this->assertContainsOnlyInstancesOf(MarkdownPage::class, $collection); - } - - public function testMarkdownPostGetHelperReturnsMarkdownPostCollection() - { - $this->shouldReceiveGlob('_posts/{*,**/*}.md')->andReturn(['_posts/test-post.md']); - $this->shouldFindFile('_posts/test-post.md'); - - $collection = MarkdownPost::all(); - $this->assertCount(1, $collection); - $this->assertInstanceOf(Collection::class, $collection); - $this->assertContainsOnlyInstancesOf(MarkdownPost::class, $collection); - } - - public function testDocumentationPageGetHelperReturnsDocumentationPageCollection() - { - $this->shouldReceiveGlob('_docs/{*,**/*}.md')->andReturn(['_docs/test-page.md']); - $this->shouldFindFile('_docs/test-page.md'); - - $collection = DocumentationPage::all(); - $this->assertCount(1, $collection); - $this->assertInstanceOf(Collection::class, $collection); - $this->assertContainsOnlyInstancesOf(DocumentationPage::class, $collection); - } - - protected function shouldReceiveGlob(string $withPath): ExpectationInterface - { - return $this->filesystem->shouldReceive('glob')->once()->with(Hyde::path($withPath), GLOB_BRACE); - } - - protected function shouldFindFile(string $file): void - { - $this->filesystem->shouldReceive('missing')->once()->with(Hyde::path($file))->andReturnFalse(); - $this->filesystem->shouldReceive('get')->once()->with(Hyde::path($file))->andReturn('content'); - } -}