mercredi 10 mai 2017

how to write test for json response?

I have function return JSON

return response()->json([
            'status' => 'OK',
            'data' => [
                'id' => $routeForecast->id,
            ],
        ])

how can I make test for this .. my laravel version is 5.1 and i used assertJson([ ]) it give me this error

***** PHPUnit_Framework_Exception: Argument #1 (No Value) of PHPUnit_Framework_Assert::assertJson() must be a string

and try seeJson it give me this error

***** Invalid JSON was returned from the route. Perhaps an exception was thrown?

how can i solve it ??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire