mirror of
https://github.com/snipe/snipe-it.git
synced 2026-03-30 04:14:17 +00:00
Spilt test scenarios
This commit is contained in:
@ -8,22 +8,35 @@ use Tests\TestCase;
|
||||
|
||||
class ViewUserTest extends TestCase
|
||||
{
|
||||
public function testPermissionsForUserDetailPage()
|
||||
|
||||
public function testRequiresPermissionToViewUser()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get(route('users.show', User::factory()->create()))
|
||||
->assertStatus(403);
|
||||
}
|
||||
|
||||
public function testCanViewUser()
|
||||
{
|
||||
$actor = User::factory()->viewUsers()->create();
|
||||
|
||||
$this->actingAs($actor)
|
||||
->get(route('users.show', User::factory()->create()))
|
||||
->assertOk()
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
public function testCannotViewUserFromAnotherCompany()
|
||||
{
|
||||
$this->settings->enableMultipleFullCompanySupport();
|
||||
|
||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||
|
||||
$superuser = User::factory()->superuser()->create();
|
||||
$actor = User::factory()->for($companyA)->viewUsers()->create();
|
||||
$user = User::factory()->for($companyB)->create();
|
||||
|
||||
$this->actingAs(User::factory()->editUsers()->for($companyA)->create())
|
||||
$this->actingAs($actor)
|
||||
->get(route('users.show', $user))
|
||||
->assertStatus(302);
|
||||
|
||||
$this->actingAs($superuser)
|
||||
->get(route('users.show', $user))
|
||||
->assertOk()
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user