Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOUR-19820 #7626

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading