Skip to content

Commit

Permalink
fix(cr) add helper for create a process from a bpmn file
Browse files Browse the repository at this point in the history
  • Loading branch information
devmiguelangel committed Nov 15, 2024
1 parent 91ac604 commit 4b1b5b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/Feature/Cases/CaseStartedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ public function test_try_store_docusign_authorization_request()
'is_system' => true,
]);

$process = Process::factory()->create([
'bpmn' => file_get_contents(base_path('tests/Feature/ImportExport/fixtures/process-docusign-authorization.bpmn.xml')),
$process = $this->createProcessFromBPMN('process-docusign-authorization.bpmn.xml', [
'process_category_id' => $category->id,
]);

Expand All @@ -482,8 +481,7 @@ public function test_try_store_error_status_on_log_error()
'is_administrator' => true,
]);

$process = Process::factory()->create([
'bpmn' => file_get_contents(base_path('tests/Feature/ImportExport/fixtures/process-abe.xml')),
$process = $this->createProcessFromBPMN('process-abe.bpmn.xml', [
'user_id' => $user->id,
]);

Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\Facades\Bus;
use PDOException;
use ProcessMaker\Jobs\RefreshArtisanCaches;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestLock;
use ProcessMaker\Models\SecurityLog;
Expand Down Expand Up @@ -106,6 +107,26 @@ protected function withPersonalAccessClient()
}
}

/**
* Create a process from a BPMN file and additional process data in PHP.
*
* @param string bpmn The `bpmn` parameter is a string that represents the name of a BPMN file located in the
* `tests/Fixtures/` directory.
* @param array attributes The `attributes` parameter is an array that allows you to pass additional data when
* creating a process from BPMN. By merging this data with the default data obtained from the BPMN file.
*
* @return The function `createProcessFromBPMN` is returning a new instance of the `Process` model that is created
* using the `factory()` method.
*/
protected function createProcessFromBPMN(string $bpmn, array $attributes = []): Process
{
$data = [
'bpmn' => file_get_contents(base_path('tests/Fixtures/' . $bpmn)),
];

return Process::factory()->create(array_merge($data, $attributes));
}

/**
* Connections transacts
*
Expand Down

0 comments on commit 4b1b5b7

Please sign in to comment.