i am trying to test one form of my website. This form is available only for logged in users. With the following code i get a failure. The html code which is returned is of the login page, so somehow the actingAs() method seems not to work ?
class AnalysesTest extends TestCase {
use DatabaseTransactions;
public function testSeeAddAnalysesForm()
{
$pass = 'mypass';
$user = $this->create_fake_user($pass);
$this->actingAs($user)
->visit('analyses/create')
->see('Save');
}
protected function create_fake_user($pass) {
$faker = Faker\Factory::create();
return App\Models\User::create([
'name' => $faker->name,
'company' => $faker->name,
'position' => 'Assistant',
'email' => $faker->email,
'phone' => $faker->phoneNumber,
'status' => 1,
'password' => $pass,
]);
}
}
The error I get is: Failed asserting that the page contains the HTML [Save]. Please check the content above.
Aucun commentaire:
Enregistrer un commentaire