Hello,
In my laravel 5.6 application I need to use php unit tests, like in file tests/Feature/VotesAdminCrudTest.php I do:
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Settings;
use App\User;
class VotesAdminCrudTest extends TestCase
{
public function testVotesListing()
{
$settingsArray = Settings::getSettingsList( ['site_name', 'site_heading', 'site_subheading'], true);
$site_name= $settingsArray['site_name' ] ? $settingsArray['site_name' ] : '';
$logged_user_id = 5;
$loggedUser= User::find($logged_user_id);
// $this->actingAs($loggedUser);
$response = $this->get('/admin/votes');
$response->assertStatus(200);
// $response->assertTitle($site_name);
$response->assertSee('Votes Listing');
}
}
But running command :
$ vendor/bin/phpunit
I got error:
Expected status code 200 but received 302.
Failed asserting that false is true.
As my /admin/votes page needs authorization, looks like that is the reason, but I do not know how to make
authorization in my case? Googling I found actingAs method, bit looks like response object has not it?
Which is the right way?
has $response object assertTitle method, I used with dusk, or subtitution of it ?