From f69a8ea28be6eabecbba12345cecef6540ea6917 Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Thu, 24 Oct 2024 17:00:25 -0400 Subject: [PATCH] FOUR-19820 --- tests/Feature/CasesControllerTest.php | 55 ++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/Feature/CasesControllerTest.php b/tests/Feature/CasesControllerTest.php index a8e6025907..0e63d80cba 100644 --- a/tests/Feature/CasesControllerTest.php +++ b/tests/Feature/CasesControllerTest.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase; use ProcessMaker\Models\ProcessRequest; +use ProcessMaker\Models\ProcessRequestToken; use ProcessMaker\Models\User; use Tests\TestCase; @@ -11,7 +12,30 @@ class CasesControllerTest extends TestCase { use RefreshDatabase; - public function test_edit_method_shows_correct_case_data_with_admin() + public function testShowCaseWithUserWithoutParticipation() + { + // Create user admin + $user = User::factory()->create(); + $this->actingAs($user); + + // Create the main request + $parentRequest = ProcessRequest::factory()->create([ + 'parent_request_id' => null, + ]); + + // Create request child + ProcessRequest::factory()->create([ + 'parent_request_id' => $parentRequest->id, + ]); + + // Call the view + $response = $this->get(route('cases.show', ['case_number' => $parentRequest->case_number])); + + // Check the status + $response->assertStatus(403); + } + + public function testShowCaseWithUserAdmin() { // Create user admin $user = User::factory()->create([ @@ -35,4 +59,33 @@ public function test_edit_method_shows_correct_case_data_with_admin() // Check the status $response->assertStatus(200); } + + public function testShowCaseWithParticipateUser() + { + // Create user + $user = User::factory()->create(); + $this->actingAs($user); + + // Create the main request + $parentRequest = ProcessRequest::factory()->create([ + 'parent_request_id' => null, + ]); + + // Create request child + ProcessRequest::factory()->create([ + 'parent_request_id' => $parentRequest->id, + ]); + + // Create the participation + ProcessRequestToken::factory()->create([ + 'process_request_id' => $parentRequest->id, + 'user_id' => $user->id, + ]); + + // Call the view + $response = $this->get(route('cases.show', ['case_number' => $parentRequest->case_number])); + + // Check the status + $response->assertStatus(200); + } }