Ad
Why Are There Multiple Assertions When Running An Http Test?
Given the test below, why do I receive the result for the expected 1 test but with 2 assertions that both pass?
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ConvertALeadTest extends TestCase
{
/** @test */
public function a_user_can_view_a_convert_page()
{
$response = $this->get('/');
$response->assertRedirect('login');
}
}
Ad
Answer
Because the assertRedirect
function has two assertions. One to check if the request returned a redirect code, and one to see if the ending location is correct.
public function assertRedirect($uri = null)
{
PHPUnit::assertTrue(
$this->isRedirect(), 'Response status code ['.$this->getStatusCode().'] is not a redirect status code.'
);
if (! is_null($uri)) {
$this->assertLocation($uri);
}
return $this;
}
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad