diff --git a/src/Models/MarkdownWithDateModel.php b/src/Models/MarkdownWithDateModel.php index eb621c1..b5fae80 100644 --- a/src/Models/MarkdownWithDateModel.php +++ b/src/Models/MarkdownWithDateModel.php @@ -8,7 +8,7 @@ use Illuminate\Support\Str; /** - * Abstract class MarkdownModel. + * Abstract class MarkdownWithDateModel. * * @property Carbon $date * @property string $slug diff --git a/tests/Models/MarkdownModelTest.php b/tests/Models/MarkdownModelTest.php index 5786457..079a286 100644 --- a/tests/Models/MarkdownModelTest.php +++ b/tests/Models/MarkdownModelTest.php @@ -10,7 +10,7 @@ class TestModel extends MarkdownModel } beforeEach(function () { - Config::set('markdown-model.path', __DIR__.'/../content'); + Config::set('markdown-model.path', __DIR__.'/../content/pages'); }); it('returns the right file calling find method', function () { @@ -50,7 +50,7 @@ class TestModel extends MarkdownModel ->toBe($fileId); }); -it('returns all files calling all methods', function () { +it('returns all files calling all method', function () { $markdowns = TestModel::all()->toArray(); expect($markdowns) diff --git a/tests/Models/MarkdownWithDateModelTest.php b/tests/Models/MarkdownWithDateModelTest.php new file mode 100644 index 0000000..12d1089 --- /dev/null +++ b/tests/Models/MarkdownWithDateModelTest.php @@ -0,0 +1,56 @@ +toArray(); + + expect($markdowns) + ->not->toBeEmpty() + ->toHaveCount(3) + ->and(array_keys($markdowns)) + ->toContain( + '2024-05-26-yet-another-test', + '2024-05-24-another-test', + '2024-05-22-test', + ); +}); + +it('should have date attribute', function () { + $markdown = TestWithDateModel::find('2024-05-26-yet-another-test'); + + expect($markdown) + ->not->toBeNull() + ->and($markdown->toArray()) + ->toHaveKey('date') + ->and($markdown->date) + ->toBeInstanceOf(Carbon::class) + ->and( + (new Carbon('2024-05-26')) + ->equalTo($markdown->date) + ) + ->toBeTrue(); +}); + +it('should have slug attribute', function () { + $markdown = TestWithDateModel::find('2024-05-26-yet-another-test'); + + expect($markdown) + ->not->toBeNull() + ->and($markdown->toArray()) + ->toHaveKey('slug') + ->and($markdown->slug) + ->toBe('yet-another-test'); +}); diff --git a/tests/content/blog/2024-05-22-test.md b/tests/content/blog/2024-05-22-test.md new file mode 100644 index 0000000..978cdc1 --- /dev/null +++ b/tests/content/blog/2024-05-22-test.md @@ -0,0 +1,7 @@ +--- +first_attribute: First attribute +second_attribute: Second attribute +third_attribute: Third attribute +--- +The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, +Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file diff --git a/tests/content/blog/2024-05-24-another-test.md b/tests/content/blog/2024-05-24-another-test.md new file mode 100644 index 0000000..978cdc1 --- /dev/null +++ b/tests/content/blog/2024-05-24-another-test.md @@ -0,0 +1,7 @@ +--- +first_attribute: First attribute +second_attribute: Second attribute +third_attribute: Third attribute +--- +The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, +Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file diff --git a/tests/content/blog/2024-05-26-yet-another-test.md b/tests/content/blog/2024-05-26-yet-another-test.md new file mode 100644 index 0000000..978cdc1 --- /dev/null +++ b/tests/content/blog/2024-05-26-yet-another-test.md @@ -0,0 +1,7 @@ +--- +first_attribute: First attribute +second_attribute: Second attribute +third_attribute: Third attribute +--- +The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, +Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file diff --git a/tests/content/folder/test.md b/tests/content/folder/test.md deleted file mode 100644 index e69de29..0000000 diff --git a/tests/content/test.md b/tests/content/pages/folder/test.md similarity index 99% rename from tests/content/test.md rename to tests/content/pages/folder/test.md index 0c424ac..978cdc1 100644 --- a/tests/content/test.md +++ b/tests/content/pages/folder/test.md @@ -3,6 +3,5 @@ first_attribute: First attribute second_attribute: Second attribute third_attribute: Third attribute --- - The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file diff --git a/tests/content/pages/test.md b/tests/content/pages/test.md new file mode 100644 index 0000000..978cdc1 --- /dev/null +++ b/tests/content/pages/test.md @@ -0,0 +1,7 @@ +--- +first_attribute: First attribute +second_attribute: Second attribute +third_attribute: Third attribute +--- +The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, +Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file diff --git a/tests/content/test2.md b/tests/content/pages/test2.md similarity index 99% rename from tests/content/test2.md rename to tests/content/pages/test2.md index 0c424ac..978cdc1 100644 --- a/tests/content/test2.md +++ b/tests/content/pages/test2.md @@ -3,6 +3,5 @@ first_attribute: First attribute second_attribute: Second attribute third_attribute: Third attribute --- - The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file diff --git a/tests/content/test3.md b/tests/content/pages/test3.md similarity index 99% rename from tests/content/test3.md rename to tests/content/pages/test3.md index 0c424ac..978cdc1 100644 --- a/tests/content/test3.md +++ b/tests/content/pages/test3.md @@ -3,6 +3,5 @@ first_attribute: First attribute second_attribute: Second attribute third_attribute: Third attribute --- - The time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't, Bruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT. \ No newline at end of file