A free open source IT asset/license management system
Spilt test scenarios
Marcus Moore0ceda098ffc0
diff --git a/tests/Feature/Users/Ui/ViewUserTest.php b/tests/Feature/Users/Ui/ViewUserTest.phpindex dd452d06e5..d2cd8a96b1 100644--- a/tests/Feature/Users/Ui/ViewUserTest.php+++ b/tests/Feature/Users/Ui/ViewUserTest.php@@ -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);}}