Reputation: 514
I've watched a video on TDD and thought to give it a try. I've set up 2 very basic tests and they are both working fine, returning the results I expect. The question is, why is the second test returning 2 assertions? The first returns a single assertion as I expected.
/** @test */
public function a_user_can_see_the_landing_page()
{
$response = $this->get('/');
$response->assertStatus(200);
}
/** @test */
public function a_user_who_isnt_signed_in_is_redirected_to_login()
{
$response = $this->get(route('home'));
$response->assertRedirect(route('login'));
}
Running this test file gives:
PHPUnit 7.4.0 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 187 ms, Memory: 14.00MB
OK (2 tests, 3 assertions)
Upvotes: 0
Views: 101
Reputation: 33206
It seems assertRedirect
actually does two assertions internally. One to check if the status code is a redirect code and one to see if the redirected url is correct.
Upvotes: 3