File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
tests/unit/Codeception/Util Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ public static function cleanCustomFilters()
9696 */
9797 public function matches (array $ jsonType )
9898 {
99- if (array_key_exists (0 , $ this ->jsonArray )) {
100- // sequential array
99+ if (array_key_exists (0 , $ this ->jsonArray ) && is_array ( $ this -> jsonArray [ 0 ]) ) {
100+ // a list of items
101101 $ msg = '' ;
102102 foreach ($ this ->jsonArray as $ array ) {
103103 $ res = $ this ->typeComparison ($ array , $ jsonType );
Original file line number Diff line number Diff line change @@ -186,4 +186,22 @@ public function testCollection()
186186 $ this ->assertContains ('3` is of type `integer:<3 ' , $ res );
187187 $ this ->assertContains ('5` is of type `integer:<3 ' , $ res );
188188 }
189+
190+ /**
191+ * @issue https://github.com/Codeception/Codeception/issues/4517
192+ */
193+ public function testMatchesArrayReturnedByFetchBoth ()
194+ {
195+ $ jsonType = new JsonType ([
196+ '0 ' => 10 ,
197+ 'a ' => 10 ,
198+ '1 ' => 11 ,
199+ 'b ' => 11 ,
200+ ]);
201+
202+ $ this ->assertTrue ($ jsonType ->matches ([
203+ 'a ' => 'integer ' ,
204+ 'b ' => 'integer ' ,
205+ ]));
206+ }
189207}
You can’t perform that action at this time.
0 commit comments