PMCORE-2193
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
5f12753187
commit
c434e13467
@@ -519,4 +519,36 @@ class TaskTest extends TestCase
|
||||
Queue::assertPushed(TaskScheduler::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the timerEventCron method with jobs in the task scheduler
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\TaskScheduler\Task::timerEventCron()
|
||||
* @dataProvider asynchronousCases
|
||||
*/
|
||||
public function it_should_test_the_timer_event_cron_method($asynchronous)
|
||||
{
|
||||
//Creates a new task
|
||||
$task = new Task($asynchronous, '');
|
||||
//Sets the currect date
|
||||
$date = date('Y-m-d H:i:s');
|
||||
//assert synchronous for cron file
|
||||
if ($asynchronous === false) {
|
||||
ob_start();
|
||||
//Calls the timerEventCron method
|
||||
$task->timerEventCron($date, true);
|
||||
//Gets the result
|
||||
$printing = ob_get_clean();
|
||||
//Asserts the result is printing that there is no exisiting records to continue a case in the determined date
|
||||
$this->assertRegExp('/No existing records to continue a case, on date "'.$date . '/', $printing);
|
||||
}
|
||||
//assert asynchronous for job process
|
||||
if ($asynchronous === true) {
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
$task->timerEventCron($date, true);
|
||||
Queue::assertPushed(TaskScheduler::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,9 +336,8 @@ try {
|
||||
$task->messageeventcron();
|
||||
break;
|
||||
case 'timereventcron':
|
||||
$timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
|
||||
|
||||
$timerEvent->startContinueCaseByTimerEvent($now, true);
|
||||
$task = new Task($asynchronous, $sObject);
|
||||
$task->timerEventCron($now, true);
|
||||
break;
|
||||
case 'sendnotificationscron':
|
||||
if (empty($argvx) || strpos($argvx, "send-notifications") !== false) {
|
||||
|
||||
@@ -22,6 +22,7 @@ use ProcessMaker\BusinessModel\Cases as BmCases;
|
||||
use ProcessMaker\BusinessModel\Light\PushMessageAndroid;
|
||||
use ProcessMaker\BusinessModel\Light\PushMessageIOS;
|
||||
use ProcessMaker\BusinessModel\MessageApplication;
|
||||
use ProcessMaker\BusinessModel\TimerEvent;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use Propel;
|
||||
@@ -598,4 +599,19 @@ class Task
|
||||
};
|
||||
$this->runTask($job);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start/Continue cases by Timer-Event
|
||||
*
|
||||
* @param string $datetime
|
||||
* @param bool $frontEnd
|
||||
*/
|
||||
public function timerEventCron($datetime, $frontEnd)
|
||||
{
|
||||
$job = function() use ($datetime, $frontEnd) {
|
||||
$timerEvent = new TimerEvent();
|
||||
$timerEvent->startContinueCaseByTimerEvent($datetime, $frontEnd);
|
||||
};
|
||||
$this->runTask($job);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user