Viewing the Response Within a Laravel PHPUnit Test


Committed to the LaraBrain by: wjgilmore (@wjgilmore) at November 4, 2015 5:55 pm

Learn how to view an integration test's response

If you're running an integration test and can't figure out exactly what the test is failing, it's often useful to see the response since it often contains error messages and other relevant information. To do so you can access the response object's getContent() method like so:

public function testCanSuccessfullyLogin()

    $user = factory(App\User::class)->create();
         ->type($user->email, 'email')             
         ->type('password', 'password')