Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanpro committed Nov 6, 2024
1 parent 6de7b60 commit 4c29cb8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 17 deletions.
31 changes: 14 additions & 17 deletions tests/Feature/Api/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,31 +819,28 @@ public function testGetUsersTaskCount()
$process = Process::factory()->create([
'user_id' => $admin->id,
]);
$request = ProcessRequest::factory()->create([
'process_id' => $process->id,
'user_id' => $admin->id,
]);

// Assign user to node_1
ProcessTaskAssignment::factory()->create([
'process_id' => $process->id,
'process_task_id' => 'node_1',
'assignment_type' => User::class,
'assignment_id' => $user->id,
]);
$bpmn = file_get_contents(__DIR__ . '/../../fixtures/task_with_user_group_assignment.bpmn');
$bpmn = str_replace([
'[assigned-users]',
'[assigned-groups]',
], [
$user->id,
$group->id,
], $bpmn);

$process->bpmn = $bpmn; // Save separately from factory::create to utilize ProcessTaskAssignmentsTrait
$process->save();

// Assign group to node_1
ProcessTaskAssignment::factory()->create([
$request = ProcessRequest::factory()->create([
'process_id' => $process->id,
'process_task_id' => 'node_1',
'assignment_type' => Group::class,
'assignment_id' => $group->id,
'user_id' => $admin->id,
]);

$tasks = ProcessRequestToken::factory(3)->create([
'process_id' => $process->id,
'process_request_id' => $request->id,
'element_id' => 'node_1',
'element_id' => 'node_2',
'user_id' => $user->id,
'status' => 'ACTIVE',
]);
Expand Down
38 changes: 38 additions & 0 deletions tests/Fixtures/task_with_user_group_assignment.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:pm="http://processmaker.com/BPMN/2.0/Schema.xsd" xmlns:tns="http://sourceforge.net/bpmn/definitions/_1530553328908" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://bpmn.sourceforge.net/schemas/BPMN20.xsd">
<bpmn:process id="ProcessId" name="ProcessName" isExecutable="true">
<bpmn:startEvent id="node_1" name="Start Event" pm:allowInterstitial="true" pm:interstitialScreenRef="" pm:config="{&#34;web_entry&#34;:null}">
<bpmn:outgoing>node_13</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="node_2" name="Form Task" pm:screenRef="17" pm:allowInterstitial="false" pm:assignment="user_group" pm:assignedUsers="[assigned-users]" pm:assignedGroups="[assigned-groups]" pm:assignmentLock="false" pm:allowReassignment="false" pm:config="{&#34;web_entry&#34;:null,&#34;email_notifications&#34;:{&#34;notifications&#34;:[]}}" pm:elementDestination="{&#34;type&#34;:&#34;taskSource&#34;,&#34;value&#34;:null}">
<bpmn:incoming>node_13</bpmn:incoming>
<bpmn:outgoing>node_22</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="node_12" name="End Event" pm:elementDestination="{&#34;type&#34;:&#34;summaryScreen&#34;,&#34;value&#34;:null}">
<bpmn:incoming>node_22</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="node_13" sourceRef="node_1" targetRef="node_2" />
<bpmn:sequenceFlow id="node_22" sourceRef="node_2" targetRef="node_12" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagramId">
<bpmndi:BPMNPlane id="BPMNPlaneId" bpmnElement="ProcessId">
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
<dc:Bounds x="330" y="220" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="470" y="220" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_12_di" bpmnElement="node_12">
<dc:Bounds x="730" y="220" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_13_di" bpmnElement="node_13">
<di:waypoint x="348" y="238" />
<di:waypoint x="528" y="258" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="node_22_di" bpmnElement="node_22">
<di:waypoint x="528" y="258" />
<di:waypoint x="748" y="238" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit 4c29cb8

Please sign in to comment.