phpunit
Match JsonStructure in PhpUnit Test – Laravel 5.4
Luckily, playing with different options I have solved this issue. A ‘*’ is expected as key if we are to match a nested object in an array. We can see the reference here. Source: TestResponse I have set the structure like this for array ofobjects` $response->assertJsonStructure([ ‘status’, ‘message’, ‘data’ => [ ‘*’ => [ ‘id’, … Read more
Creating a mock in phpunit without mocking any methods?
You can pass null to setMethods() to avoid mocking any methods. Passing an empty array will mock all methods. The latter is the default value for the methods as you’ve found. That being said, I would say the need to do this might point out a flaw in the design of this class. Should this … Read more