Skip to content

Commit

Permalink
Tested PR
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos committed Oct 16, 2015
1 parent eb8e3d8 commit 8ea6ba0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 22 additions & 0 deletions spec/Fenos/Notifynder/Parsers/NotifynderParserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,26 @@ function it_will_throw_exception_when_strict_extra_is_enabled()
$this->shouldThrow(ExtraParamsException::class)
->during('parse',[$notification]);
}

/** @test */
function it_will_parse_4_extra_params()
{
$extra = [
'name' => 'fabri',
'username' => 'fenos',
'status' => 'active',
'prof' => 'dev'
];

$text = 'Hi {extra.name}, your username is: {extra.username} your status: {extra.status} your profession: {extra.prof}';
$notification = [
'body' => [
'text' => $text
],
'extra' => json_encode($extra)
];

$parsedText = "Hi {$extra['name']}, your username is: {$extra['username']} your status: {$extra['status']} your profession: {$extra['prof']}";
$this->parse($notification)->shouldReturn($parsedText);
}
}
5 changes: 2 additions & 3 deletions src/Notifynder/Parsers/NotifynderParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ protected function categorizeSpecialValues($specialValues)
*/
protected function replaceExtraValues($extrasToReplace, $extra, $body)
{
// replace the values specified in the extra

// Whichever type i
// I'll try my best to have returned the
// extra param as an array
$extra = $this->extraToArray($extra);

// wildcard
Expand Down

0 comments on commit 8ea6ba0

Please sign in to comment.