-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cea970b
commit f173b89
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hyde\Framework\Testing\Unit; | ||
|
||
use Hyde\Testing\TestCase; | ||
use Illuminate\Support\Str; | ||
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile; | ||
|
||
/** | ||
* @covers \Hyde\Framework\Actions\CreatesNewMarkdownPostFile | ||
* @see \Hyde\Framework\Testing\Feature\Commands\MakePostCommandTest | ||
*/ | ||
class CreatesNewMarkdownPostFileTest extends TestCase | ||
{ | ||
public function testWithDefaultData() | ||
{ | ||
$action = new CreatesNewMarkdownPostFile('Example Title', null, null, null); | ||
$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' => '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); | ||
} | ||
} |