Skip to content

Commit ae7175f

Browse files
committed
Fixed positive matching
1 parent 3b6cdd5 commit ae7175f

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/Codeception/Util/JsonArray.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ private function sequentialArrayIntersect($arr1, $arr2)
122122
if ($value1 === $value2 && !isset($matchedKeys[$key2])) {
123123
$ret[$key1] = $value1;
124124
$matchedKeys[$key2] = true;
125+
break;
125126
}
126127
}
127128
}

tests/unit/Codeception/Util/JsonArrayTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,19 @@ public function testContainsArrayComparesArrayWithMultipleZeroesCorrectly()
7474
$this->assertFalse($jsonArray->containsArray($expectedArray));
7575
}
7676

77-
public function testContainsArrayComparesArrayWithValueRepeatedMultipleTimesCorrectly()
77+
public function testContainsArrayComparesArrayWithValueRepeatedMultipleTimesCorrectlyNegativeCase()
7878
{
7979
$jsonArray = new JsonArray(json_encode(['foo', 'foo', 'bar']));
8080
$expectedArray = ['foo', 'foo', 'foo'];
8181
$this->assertFalse($jsonArray->containsArray($expectedArray));
8282
}
83+
84+
85+
86+
public function testContainsArrayComparesArrayWithValueRepeatedMultipleTimesCorrectlyPositiveCase()
87+
{
88+
$jsonArray = new JsonArray(json_encode(['foo', 'foo', 'bar']));
89+
$expectedArray = ['foo', 'bar', 'foo'];
90+
$this->assertTrue($jsonArray->containsArray($expectedArray));
91+
}
8392
}

0 commit comments

Comments
 (0)