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
6 changes: 4 additions & 2 deletions ProcessMaker/Repositories/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ public function persistActivityActivated(ActivityInterface $activity, TokenInter
/**
* Get due Variable
*
* @param Instance $instance
* @param User $user
* @param ActivityInterface $activity
* @param TokenInterface $token
*
* @return integer
*/
private function getDueVariable(ActivityInterface $activity, TokenInterface $token)
{
Expand Down
24 changes: 24 additions & 0 deletions tests/Feature/Api/TaskAssignmentExecutionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Feature\Api;

use Carbon\Carbon;
use ProcessMaker\Exception\ThereIsNoProcessManagerAssignedException;
use ProcessMaker\Facades\WorkflowManager;
use ProcessMaker\Models\Group;
Expand Down Expand Up @@ -140,6 +141,29 @@ public function testUserByIdAssignment()
$this->assertFalse(array_key_exists('errors', $response));
}

public function testDueDate()
{
$process = Process::factory()->create([
'bpmn' => file_get_contents(__DIR__ . '/processes/TaskConfiguredCustomDueIn.bpmn'),
]);
$data = [
'var_due_date' => 24
];
$route = route('api.process_events.trigger',
[$process->id, 'event' => 'node_1']);
$response = $this->apiCall('POST', $route, $data);
// Verify status
$response->assertStatus(201);
// Get the ProcessRequest
$expectedDueDate = Carbon::now()->addHours(24);
$task = ProcessRequestToken::where([
'process_request_id' => $response['id'],
'status' => 'ACTIVE',
])->firstOrFail();

$this->assertFalse($task->due_at->greaterThanOrEqualTo($expectedDueDate));
}

public function testSelfServeAssignment()
{
$users = User::factory()->count(20)->create(['status'=>'ACTIVE']);
Expand Down
38 changes: 38 additions & 0 deletions tests/Feature/Api/processes/TaskConfiguredCustomDueIn.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="46" pm:config="{&#34;web_entry&#34;:null}">
<bpmn:outgoing>node_29</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="node_2" name="Form Task" pm:allowInterstitial="false" pm:dueInVariable="{{var_due_date}}" pm:isDueInVariable="true" pm:assignment="requester" pm:assignmentLock="false" pm:allowReassignment="false" pm:config="{&#34;web_entry&#34;:null,&#34;email_notifications&#34;:{&#34;notifications&#34;:[]}}">
<bpmn:incoming>node_29</bpmn:incoming>
<bpmn:outgoing>node_38</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="node_20" name="End Event">
<bpmn:incoming>node_38</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="node_29" sourceRef="node_1" targetRef="node_2" />
<bpmn:sequenceFlow id="node_38" sourceRef="node_2" targetRef="node_20" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagramId">
<bpmndi:BPMNPlane id="BPMNPlaneId" bpmnElement="ProcessId">
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
<dc:Bounds x="236" y="163" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="341" y="145" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_20_di" bpmnElement="node_20">
<dc:Bounds x="507" y="166" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_29_di" bpmnElement="node_29">
<di:waypoint x="254" y="181" />
<di:waypoint x="399" y="183" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="node_38_di" bpmnElement="node_38">
<di:waypoint x="399" y="183" />
<di:waypoint x="525" y="184" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>