I want to test, whether an AJAX response contains the array I'm expecting.
So far so good, not really a great deal.
This is how my array should look like:
array (
'data' =>
array (
0 =>
array (
'key1' => 'value1',
'key2' => 'value2,
),
1 =>
array (
'key1' => 'value3',
'key2' => "value4",
),
),
)
When I run my test:
$request->assertJson([the array mentioned above]);
The array really looks like that but it fails anyway. Why?
because in reality it expects the array twice.
In the comparison window, I see that it expects this:
array (
'data' =>
array (
0 =>
array (
'key1' => 'value1',
'key2' => 'value2,
),
1 =>
array (
'key1' => 'value3',
'key2' => "value4",
),
),
0 =>
array (
'key1' => 'value1',
'key2' => 'value2,
),
1 =>
array (
'key1' => 'value3',
'key2' => "value4",
),
)
But got the array mentioned above (which would be what I expect too).
When I run $request->assertJSON([]);
the test succeeds but this can't be the way it's supposed to work, is it?