Skip to content
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
8 changes: 6 additions & 2 deletions ProcessMaker/Jobs/RunServiceTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ProcessMaker\Jobs;

use Exception;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Exception\ConfigurationException;
Expand Down Expand Up @@ -127,8 +128,11 @@ public function action(ProcessRequestToken $token = null, ServiceTaskInterface $
$error->setName($message);

$token->setProperty('error', $error);
$exceptionClass = get_class($exception);
$modifiedException = new $exceptionClass($message);
if ($message !== $exception->getMessage()) {
$modifiedException = new Exception($message, $exception->getCode(), $exception);
} else {
$modifiedException = $exception;
}
$token->logError($modifiedException, $element);

Log::error('Service task failed: ' . $implementation . ' - ' . $message);
Expand Down
31 changes: 26 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
namespace Tests;

use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Illuminate\Database\DatabaseManager;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Bus;
use PDOException;
use ProcessMaker\ImportExport\Importer;
use ProcessMaker\ImportExport\Options;
use ProcessMaker\Jobs\RefreshArtisanCaches;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestLock;
use ProcessMaker\Models\SecurityLog;
use ProcessMaker\Models\Setting;

abstract class TestCase extends BaseTestCase
{
Expand Down Expand Up @@ -127,6 +124,30 @@ protected function createProcessFromBPMN(string $bpmnFile, array $attributes = [
return Process::factory()->create(array_merge($data, $attributes));
}

/**
* Creates a Process instance from a JSON file.
*
* This method reads the specified JSON file, merges the provided attributes,
* and creates a new Process instance.
*
* @param string $jsonFile The path to the JSON file containing the process definition.
* @param array $attributes Additional attributes to merge into the process definition.
* @return Process The created Process instance.
*/
protected function createProcessFromJSON(string $jsonFile, array $attributes = []): Process
{
$payload = json_decode(file_get_contents($jsonFile), true);
$options = new Options([]);
$importer = new Importer($payload, $options);
$importer->previewImport();
$manifest = $importer->doImport();
$processId = $manifest[$payload['root']]->log['newId'];
$process = Process::find($processId);
$process->update($attributes);

return $process;
}

/**
* Connections transacts
*
Expand Down