mardi 26 février 2019

Laravel API Illuminate\Foundation\Testing\TestResponse empty array when expecting single object

Why is it that from a unit test in Laravel if I do the following request, decode the json response, it comes back as an empty array:

$response = $this->get(route('api.inspections.get', [
    "id" => $inspection->id
]));

$apiInspection = $response->json(); # Empty array :(

Yet doing the most basic get request to that same URL gets me a nice json response.

$inspection = file_get_contents(route('api.inspections.get', [
    "id" => $inspection->id
]));
$inspection = json_decode($inspection); # The expected inspection stdClass

Thanks



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NwwBvy
via IFTTT

Aucun commentaire:

Enregistrer un commentaire