PMCORE-2644
This commit is contained in:
@@ -557,4 +557,33 @@ class TaskTest extends TestCase
|
|||||||
Queue::assertPushed(TaskScheduler::class);
|
Queue::assertPushed(TaskScheduler::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the webEntriesCron method with jobs in the task scheduler
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\TaskScheduler\Task::runTask()
|
||||||
|
* @covers ProcessMaker\TaskScheduler\Task::webEntriesCron()
|
||||||
|
* @dataProvider asynchronousCases
|
||||||
|
*/
|
||||||
|
public function it_should_test_webEntriesCron_method($asynchronous)
|
||||||
|
{
|
||||||
|
$task = new Task($asynchronous, '');
|
||||||
|
|
||||||
|
//assert synchronous for cron file
|
||||||
|
if ($asynchronous === false) {
|
||||||
|
ob_start();
|
||||||
|
$task->webEntriesCron();
|
||||||
|
$printing = ob_get_clean();
|
||||||
|
$this->assertEmpty($printing);
|
||||||
|
}
|
||||||
|
|
||||||
|
//assert asynchronous for job process
|
||||||
|
if ($asynchronous === true) {
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
$task->webEntriesCron();
|
||||||
|
Queue::assertPushed(TaskScheduler::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Kernel;
|
use Illuminate\Foundation\Http\Kernel;
|
||||||
use ProcessMaker\BusinessModel\Cases;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../gulliver/system/class.g.php';
|
require_once __DIR__ . '/../../../gulliver/system/class.g.php';
|
||||||
require_once __DIR__ . '/../../../bootstrap/autoload.php';
|
require_once __DIR__ . '/../../../bootstrap/autoload.php';
|
||||||
require_once __DIR__ . '/../../../bootstrap/app.php';
|
require_once __DIR__ . '/../../../bootstrap/app.php';
|
||||||
|
|
||||||
use ProcessMaker\BusinessModel\WebEntry;
|
|
||||||
use ProcessMaker\Core\JobsManager;
|
use ProcessMaker\Core\JobsManager;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
@@ -349,9 +347,8 @@ try {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'webentriescron':
|
case 'webentriescron':
|
||||||
setExecutionMessage('Deleting web entry cases created one week ago or more');
|
$task = new Task($asynchronous, $sObject);
|
||||||
WebEntry::deleteOldWebEntries();
|
$task->webEntriesCron();
|
||||||
setExecutionResultMessage('FINISHED');
|
|
||||||
break;
|
break;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
case 'actionsByEmailEmailResponse':
|
case 'actionsByEmailEmailResponse':
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ use ProcessMaker\BusinessModel\Light\PushMessageAndroid;
|
|||||||
use ProcessMaker\BusinessModel\Light\PushMessageIOS;
|
use ProcessMaker\BusinessModel\Light\PushMessageIOS;
|
||||||
use ProcessMaker\BusinessModel\MessageApplication;
|
use ProcessMaker\BusinessModel\MessageApplication;
|
||||||
use ProcessMaker\BusinessModel\TimerEvent;
|
use ProcessMaker\BusinessModel\TimerEvent;
|
||||||
|
use ProcessMaker\BusinessModel\WebEntry;
|
||||||
use ProcessMaker\Core\JobsManager;
|
use ProcessMaker\Core\JobsManager;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
use Propel;
|
use Propel;
|
||||||
@@ -684,4 +685,20 @@ class Task
|
|||||||
};
|
};
|
||||||
$this->runTask($job);
|
$this->runTask($job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deleting web entry cases created one week ago or more
|
||||||
|
*/
|
||||||
|
public function webEntriesCron()
|
||||||
|
{
|
||||||
|
$scheduledTaskIdentifier = uniqid(__FUNCTION__ . "#");
|
||||||
|
Log::channel('taskScheduler:taskScheduler')->info("Start {$scheduledTaskIdentifier}", Bootstrap::context());
|
||||||
|
|
||||||
|
$job = function() use ($scheduledTaskIdentifier) {
|
||||||
|
WebEntry::deleteOldWebEntries();
|
||||||
|
|
||||||
|
Log::channel('taskScheduler:taskScheduler')->info("Finish {$scheduledTaskIdentifier}", Bootstrap::context());
|
||||||
|
};
|
||||||
|
$this->runTask($job);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user