From f173b891a2ad5393214c579a23e4403867160202 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Oct 2023 16:59:54 +0200 Subject: [PATCH] Add unit test --- .../Unit/CreatesNewMarkdownPostFileTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php diff --git a/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php b/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php new file mode 100644 index 00000000000..cfa638c32f7 --- /dev/null +++ b/packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php @@ -0,0 +1,50 @@ +toArray(); + + // Truncate date as it can cause tests to fail when the clock switches over a second + $array['date'] = Str::before($array['date'], ' '); + + $this->assertSame([ + 'title' => 'Example Title', + 'description' => 'A short description used in previews and SEO', + 'category' => 'blog', + 'author' => 'default', + 'date' => date('Y-m-d'), + ], $array); + } + + public function testWithCustomData() + { + $action = new CreatesNewMarkdownPostFile('foo', 'bar', 'baz', 'qux'); + $array = $action->toArray(); + + // Truncate date as it can cause tests to fail when the clock switches over a second + $array['date'] = Str::before($array['date'], ' '); + + $this->assertSame([ + 'title' => 'foo', + 'description' => 'bar', + 'category' => 'baz', + 'author' => 'qux', + 'date' => date('Y-m-d'), + ], $array); + } +}