Skip to content

Commit

Permalink
[2.3] Fix bad encoding in Repeat expander (#113)
Browse files Browse the repository at this point in the history
* Fix encoding

* Fix tests
  • Loading branch information
eliecharra authored and norberttech committed Nov 18, 2017
1 parent 7b2cb77 commit d6b3ad8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Matcher/Pattern/Expander/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function matchScalar(array $values, Matcher $matcher)
$match = $matcher->match($value, $this->pattern);

if (!$match) {
$this->error = sprintf("Repeat expander, entry n°%d, find error : %s", $index, $matcher->getError());
$this->error = sprintf("Repeat expander, entry n°%d, find error : %s", $index, $matcher->getError());
return false;
}
}
Expand Down Expand Up @@ -129,14 +129,14 @@ private function matchJson(array $values, Matcher $matcher)

foreach ($patternKeys as $key) {
if (!array_key_exists($key, $value)) {
$this->error = sprintf("Repeat expander, entry n°%d, require \"array\" to have key \"%s\".", $index, $key);
$this->error = sprintf("Repeat expander, entry n°%d, require \"array\" to have key \"%s\".", $index, $key);
return false;
}

$match = $matcher->match($value[$key], $this->pattern[$key]);

if (!$match) {
$this->error = sprintf("Repeat expander, entry n°%d, key \"%s\", find error : %s", $index, $key, $matcher->getError());
$this->error = sprintf("Repeat expander, entry n°%d, key \"%s\", find error : %s", $index, $key, $matcher->getError());
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Matcher/Pattern/Expander/RepeatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public static function invalidCasesProvider()
);

return array(
array($pattern, $valueTest, 'Repeat expander, entry n°0, key "name", find error : integer "1" is not a valid string.'),
array($pattern, $keyTest, 'Repeat expander, entry n°0, require "array" to have key "name".'),
array($pattern, $valueTest, 'Repeat expander, entry n°0, key "name", find error : integer "1" is not a valid string.'),
array($pattern, $keyTest, 'Repeat expander, entry n°0, require "array" to have key "name".'),
array($pattern, $strictTest, 'Repeat expander expect to have 2 keys in array but get : 3'),
array($pattern, "", 'Repeat expander require "array", got "".')
);
Expand Down

0 comments on commit d6b3ad8

Please sign in to comment.