mercredi 6 mars 2019

Lumen phpunit get request fails and gives 500 when I access the uri parameter via $request->route('whatever')

I'm sending a a get request via lumen unittesting using $this->get('api/cars/volvo/'), where volvo is a route parameter, but when this request reaches my controller, it gives me 500 because I'm accessing this uri parameter through $request->route('company'). Note that this only occurs when I send request through unittest, not the normal request if I send forexample from postman.

Example: $response = $this->get('/api/v1/cars/volvo, $header); $response->assertResponseStatus(200);

I get the follwing when I run this test: 1) Tests\ApiTest::test_get_cars Expected status code 200, got 500. Failed asserting that 500 matches expected 200.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire