Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Apr 15, 2014
2 parents e8fcb14 + de2a5c2 commit 07ff7ad
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![Build Status](https://travis-ci.org/defrag/JsonMatcher.svg)](https://travis-ci.org/defrag/JsonMatcher)
2 changes: 1 addition & 1 deletion src/JsonMatcher/Matcher/ArrayMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function match($value, $pattern)
$accessorBuilder->enableExceptionOnInvalidIndex();
$accessor = $accessorBuilder->getPropertyAccessor();

$this->paths = [];
$this->paths = array();
foreach ($value as $key => $element) {
$path = sprintf("[%s]", $key);

Expand Down
45 changes: 25 additions & 20 deletions tests/JsonMatcher/ArrayMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class ArrayMatcherTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->simpleArray = [
'users' => [
[
$this->simpleArray = array(
'users' => array(
array(
'firstName' => 'Norbert',
'lastName' => 'Orzechowicz'
],
[
),
array(
'firstName' => 'Michał',
'lastName' => 'Dąbrowski'
]
],
)
),
true,
false,
1,
6.66
];
);
}

public function test_match_arrays()
Expand All @@ -36,21 +36,26 @@ public function test_match_arrays()
$matcher = new ArrayMatcher($chain);

$this->assertTrue($matcher->match($this->simpleArray, $this->simpleArray));
$this->assertTrue($matcher->match([], []));
$this->assertFalse($matcher->match($this->simpleArray, []));
$this->assertFalse($matcher->match(['foo', 1, 3], ['foo', 2, 3]));
$this->assertFalse($matcher->match($this->simpleArray, [6, 6.66, false, false, [1, 2, 'foo'], ['foo' => 'bar2'], null]));
$this->assertFalse($matcher->match($this->simpleArray, [
'users' => [
[
$this->assertTrue($matcher->match(array(), array()));
$this->assertFalse($matcher->match($this->simpleArray, array()));
$this->assertFalse($matcher->match(array('foo', 1, 3), array('foo', 2, 3)));
$this->assertFalse($matcher->match($this->simpleArray, array(6, 6.66, false, false, array(1, 2, 'foo'), array('foo' => 'bar2'), null)));
$this->assertFalse($matcher->match($this->simpleArray, array(
'users' => array(
array(
'firstName' => 'Pawel',
'lastName' => 'Orzechowicz'
],
[
),
array(
'firstName' => 'Michał',
'lastName' => 'Dąbrowski'
]
]
]));
)
),
true,
false,
1,
6.66
)));
}

}

0 comments on commit 07ff7ad

Please sign in to comment.