Skip to content

Commit

Permalink
FOUR-19820
Browse files Browse the repository at this point in the history
  • Loading branch information
pmPaulis committed Oct 24, 2024
1 parent af235d6 commit f69a8ea
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion tests/Feature/CasesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,38 @@

use Illuminate\Foundation\Testing\RefreshDatabase;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\Models\User;
use Tests\TestCase;

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([
Expand All @@ -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);
}
}

0 comments on commit f69a8ea

Please sign in to comment.