Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
assertArraySubset() does not work as expected #3240
After upgrade to phpunit
<?php // the following lines emulate a response // from other library that return a array of stdClass $field1 = new \stdClass(); $field1->name = 'amount'; $field1->required = true; $field2 = new \stdClass(); $field2->name = 'accountNumber'; $field2->required = true; $dataArray = [$field1, $field2]; // end of emulation //-> TEST // convert the response in stdClass into associative array $array = json_decode(json_encode($dataArray), true); $subset = [ [ 'name' => 'amount', 'required' => true, ], ]; Assert::assertArraySubset($subset, $array);
The first part of the example is only for demonstration, really I use another library to get a JSON response (the library return that response using stdClass). But the point is, for some reason after convert this data to array the
This might be what was mentioned in #3161 (comment).
To be honest, I do not know how this is expected to work as I never used
@marcioAlmada originally implemented
changed the title
PHPUnit 7.3: assertArraySubset does not work as expected
Aug 4, 2018
The good news is that there is already a PR that fixes this: #3186. I will add the test for this case to that PR to prove that this is conclusively fixed.