From 73f3439d0872cd4c6ff8311eae1d7ce273533124 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Oct 2023 17:14:09 +0200 Subject: [PATCH] Unit test save method --- .../Unit/CreatesNewMarkdownPostFileTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php b/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php index e7b320f1f6f..01f93b83d02 100644 --- a/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php +++ b/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Testing\Unit; +use Hyde\Hyde; use Hyde\Testing\TestCase; use Illuminate\Support\Carbon; use Hyde\Framework\Actions\CreatesNewMarkdownPostFile; @@ -46,4 +47,29 @@ public function testWithCustomData() 'date' => '2024-01-01 00:00', ], $array); } + + public function testSave() + { + Carbon::setTestNow(Carbon::create(2024)); + + $action = new CreatesNewMarkdownPostFile('Example Post', null, null, null); + $action->save(); + + $path = Hyde::path('_posts/example-post.md'); + + $this->assertSame(<<<'MARKDOWN' + --- + title: 'Example Post' + description: 'A short description used in previews and SEO' + category: blog + author: default + date: '2024-01-01 00:00' + --- + + ## Write something awesome. + + MARKDOWN, file_get_contents($path)); + + unlink($path); + } }