samedi 16 juin 2018

Why do I get a "Invalid JSON" when Status Code 204?

I don't know if it is intended or not. But when I use a Reponse Code 204 in my Controller I get "Invalid JSON was returned from the route" in PHPunit.

But if I change the Response Code to 201, everything works fine... Why?

protected function output($title, $status = 201)
{
    return response([
        'title' => $title,
        'offers' => $this->popular,
    ], $status);
}

$this->output('Empty', 204); //Here is the error

In my test

/** @test */
public function popular_can_fetch_food_lists() {
    $result = $this->json('post', route('popular', [
        'type' => $this->food->type,
        'id' => $this->food->id
    ]))->json();
}



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

Aucun commentaire:

Enregistrer un commentaire