Laravel Assertable Json

Photo by Jason Briscoe on Unsplash
public function test_fluent_json()
{
$response = $this->getJson('/vehicles/1'); $response
->assertJson(fn (AssertableJson $json) =>
$json->where('id', 1)
->where('name', 'Model T')
->missing('new')
->etc()
);
}
Photo by Jan Kopřiva on Unsplash
$response->assertJson(fn (AssertableJson $json) =>   $json->has('description'););
$response->assertJson(fn (AssertableJson $json) =>   $json->has(3););
$response->assertJson(fn (AssertableJson $json) =>   $json->has('vehicles', 3)
->has('vehicle.0', fn ($json) =>
$json->where('id', 5)
->where('name', 'Model S')
)
);
Photo by Pawel Czerwinski on Unsplash

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store