diff --git a/ProcessMaker/Repositories/TokenRepository.php b/ProcessMaker/Repositories/TokenRepository.php index 77256e3447..471e42d34b 100644 --- a/ProcessMaker/Repositories/TokenRepository.php +++ b/ProcessMaker/Repositories/TokenRepository.php @@ -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) { diff --git a/tests/Feature/Api/TaskAssignmentExecutionTest.php b/tests/Feature/Api/TaskAssignmentExecutionTest.php index 354480ae27..ddb4fbbd65 100644 --- a/tests/Feature/Api/TaskAssignmentExecutionTest.php +++ b/tests/Feature/Api/TaskAssignmentExecutionTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Api; +use Carbon\Carbon; use ProcessMaker\Exception\ThereIsNoProcessManagerAssignedException; use ProcessMaker\Facades\WorkflowManager; use ProcessMaker\Models\Group; @@ -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']); diff --git a/tests/Feature/Api/processes/TaskConfiguredCustomDueIn.bpmn b/tests/Feature/Api/processes/TaskConfiguredCustomDueIn.bpmn new file mode 100644 index 0000000000..92376e5433 --- /dev/null +++ b/tests/Feature/Api/processes/TaskConfiguredCustomDueIn.bpmn @@ -0,0 +1,38 @@ + + + + + node_29 + + + node_29 + node_38 + + + node_38 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file