-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #396 from hydephp/improve-array-to-front-matter-ac…
…tion Improve ConvertsArrayToFrontMatter action hydephp/develop@f703f5e
- Loading branch information
github-actions
committed
Aug 10, 2022
1 parent
5715ee6
commit 41d8f83
Showing
3 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
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
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
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,44 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Testing\Feature; | ||
|
||
use Hyde\Framework\Actions\ConvertsArrayToFrontMatter; | ||
use Hyde\Testing\TestCase; | ||
|
||
/** | ||
* @covers \Hyde\Framework\Actions\ConvertsArrayToFrontMatter | ||
*/ | ||
class ConvertsArrayToFrontMatterTest extends TestCase | ||
{ | ||
public function test_action_converts_an_array_to_front_matter() | ||
{ | ||
$array = [ | ||
'key' => 'value', | ||
'string' => 'quoted string', | ||
'boolean' => true, | ||
'integer' => 100, | ||
'array' => ['key' => 'value'], | ||
'list' => ['foo', 'bar'], | ||
]; | ||
$expected = <<<'YAML' | ||
--- | ||
key: value | ||
string: 'quoted string' | ||
boolean: true | ||
integer: 100 | ||
array: | ||
key: value | ||
list: | ||
- foo | ||
- bar | ||
--- | ||
|
||
YAML; | ||
$this->assertEquals(str_replace("\r", '', $expected), (new ConvertsArrayToFrontMatter)->execute($array)); | ||
} | ||
|
||
public function test_action_returns_empty_string_if_array_is_empty() | ||
{ | ||
$this->assertEquals('', (new ConvertsArrayToFrontMatter)->execute([])); | ||
} | ||
} |