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-21966 Do not log error case log when system like processes without case are updated #8033

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions ProcessMaker/Repositories/CaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function create(ExecutionInstanceInterface $instance): void
public function update(ExecutionInstanceInterface $instance, TokenInterface $token): void
{
if (!$this->checkIfCaseStartedExist($instance->case_number)) {
Log::error('case started not found, method=update, instance=' . $instance->getKey());

return;
}
Expand Down Expand Up @@ -119,7 +118,6 @@ public function update(ExecutionInstanceInterface $instance, TokenInterface $tok
public function updateStatus(ExecutionInstanceInterface $instance): void
{
if (is_null($instance->case_number)) {
Log::error('case started not found, method=updateStatus, instance=' . $instance->getKey());

return;
}
Expand Down
34 changes: 27 additions & 7 deletions tests/Feature/Cases/CaseExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Tests\Feature\Cases;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessCategory;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\Models\User;
Expand Down Expand Up @@ -123,13 +125,31 @@ public function test_update_case_missing_case_started(): void

$this->assertDatabaseCount('cases_started', 0);

try {
$repo->update($this->instance, $this->token);
} catch (\Exception $e) {
$this->assertEquals(
'case started not found, method=update, instance=' . $this->instance->getKey(), $e->getMessage()
);
}
$repo->update($this->instance, $this->token);
}

public function test_update_case_system_process(): void
{
$this->withoutExceptionHandling();
$process = Process::factory()->create([
'process_category_id' => ProcessCategory::factory()->create(['is_system' => true])->id,
]);
$instance = ProcessRequest::factory()->create([
'user_id' => $this->user->id,
'process_id' => $process->id,
]);

$instance->case_title = null;
$repo = new CaseRepository();
$repo->create($instance);

$this->assertDatabaseCount('cases_started', 0);

Log::shouldReceive('error')->never()->withAnyArgs();
$repo->update($instance, $this->token);

Log::shouldReceive('error')->never()->withAnyArgs();
$repo->updateStatus($instance, $this->token);
}

public function test_artisan_sync_command_missing_ids(): void
Expand Down
Loading