From 0ceda098ffc02ff900417891358df3b0dcda50d6 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 20 Mar 2025 16:10:01 -0700 Subject: [PATCH] Spilt test scenarios --- tests/Feature/Users/Ui/ViewUserTest.php | 29 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/Feature/Users/Ui/ViewUserTest.php b/tests/Feature/Users/Ui/ViewUserTest.php index 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); } }