I would say it's a unit test since it test the $user->assignRole() method.
Yes a unit test can talk to the database if it needs to.
Could a unit test use databases?
I mean, i want to make a test that assert if a give role has been assigned
/** @test */
public function a_admin_is_an_admin()
{
$user = factory(\App\User::class)->create();
$role = factory(\App\Role::class)->create(['name' => 'Admin', 'label' => 'Amministratore']);
$user->assignRole($role);
$this->assertEquals(true, $user->isAdmin());
}
Is this an unit or a feature test?
If it is a Unit test, should it use database?
If not how i can rewrite this?
I would say it's a unit test since it test the $user->assignRole() method.
Yes a unit test can talk to the database if it needs to.
Please or to participate in this conversation.