3
0
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:
Marcus Moore
2025-03-20 16:10:01 -07:00
parent db81209fe1
commit 0ceda098ff

View File

@ -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);
}
}