diff --git a/packages/framework/tests/Unit/DataCollectionUnitTest.php b/packages/framework/tests/Unit/DataCollectionUnitTest.php index 3a78022ee93..e5d17ea17f7 100644 --- a/packages/framework/tests/Unit/DataCollectionUnitTest.php +++ b/packages/framework/tests/Unit/DataCollectionUnitTest.php @@ -10,6 +10,7 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Collection; use Mockery; +use Hyde\Markdown\Models\MarkdownDocument; /** * @covers \Hyde\Support\DataCollection @@ -100,6 +101,23 @@ public function testStaticMarkdownHelperReturnsNewDataCollectionInstance() { $this->assertInstanceOf(DataCollection::class, DataCollection::markdown('foo')); } + + public function testMarkdownMethodReturnsCollectionOfMarkdownDocuments() + { + MockableDataCollection::mockFiles([ + 'foo/bar.md' => 'bar', + 'foo/baz.md' => 'baz', + ]); + + $collection = MockableDataCollection::markdown('foo'); + + $this->assertContainsOnlyInstancesOf(MarkdownDocument::class, $collection); + + $this->assertSame([ + 'bar' => 'bar', + 'baz' => 'baz', + ], $collection->map(fn ($value) => (string) $value)->all()); + } } class MockableDataCollection extends DataCollection