lundi 4 décembre 2017

Laravel test php unit return error 500

I'm trying to test my Web application developed with Laravel.

I have a UsersTest.php with a simple function:

public function testGetUsers(){
        $response = $this->json('POST', '/getUsers', []);
        $response->assertStatus(200);
    }

In web.php route I have simply:

Route::post('getUsers', 'UsersController@getUsers');

And in my controller I put a response:

public function getUsers(Request $request){
        return response()->json([], 200);
}

But It fails test with this error:

1) Tests\Unit\UserTest::testGetUsers Expected status code 200 but received 500. Failed asserting that false is true.

What I'm wrong in my test?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire