PMCORE-2190 Migrate to queue job - Cron File: messageeventcron.php - Start Message Events
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
041434aa42
commit
5f12753187
@@ -9,10 +9,10 @@ use ProcessMaker\TaskScheduler\Task;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class TaskTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\TaskScheduler\Task
|
||||
*/
|
||||
* Class TaskTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\TaskScheduler\Task
|
||||
*/
|
||||
class TaskTest extends TestCase
|
||||
{
|
||||
private $faker;
|
||||
@@ -129,19 +129,25 @@ class TaskTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_saveLog_method($asynchronous)
|
||||
{
|
||||
$task = new Task($asynchronous, '');
|
||||
$description = $this->faker->paragraph;
|
||||
|
||||
$task->saveLog('', '', $description);
|
||||
$task = new Task(false, '');
|
||||
$task->saveLog('', '', $this->faker->paragraph);
|
||||
$file = PATH_DATA . "log/cron.log";
|
||||
$this->markTestIncomplete('Please solve the error related to unit test');
|
||||
$this->assertFileExists($file);
|
||||
|
||||
if ($asynchronous === false) {
|
||||
$description = $this->faker->paragraph;
|
||||
$task = new Task($asynchronous, '');
|
||||
$task->saveLog('', '', $description);
|
||||
$contentLog = file_get_contents($file);
|
||||
|
||||
$this->assertRegExp("/{$description}/", $contentLog);
|
||||
}
|
||||
if ($asynchronous === true) {
|
||||
$description = $this->faker->paragraph;
|
||||
$task = new Task($asynchronous, '');
|
||||
$task->saveLog('', '', $description);
|
||||
$contentLog = file_get_contents($file);
|
||||
|
||||
$this->assertNotRegExp("/{$description}/", $contentLog);
|
||||
}
|
||||
}
|
||||
@@ -485,4 +491,32 @@ class TaskTest extends TestCase
|
||||
Queue::assertPushed(TaskScheduler::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verify the messageeventcron activity method for synchronous and asynchronous execution.
|
||||
* @test
|
||||
* @covers ProcessMaker\TaskScheduler\Task::runTask()
|
||||
* @covers ProcessMaker\TaskScheduler\Task::messageeventcron()
|
||||
* @dataProvider asynchronousCases
|
||||
*/
|
||||
public function it_should_test_messageeventcron_method($asynchronous)
|
||||
{
|
||||
$task = new Task($asynchronous, '');
|
||||
|
||||
//assert synchronous for cron file
|
||||
if ($asynchronous === false) {
|
||||
ob_start();
|
||||
$task->messageeventcron();
|
||||
$printing = ob_get_clean();
|
||||
$this->assertRegExp("/Message-Events/", $printing);
|
||||
}
|
||||
|
||||
//assert asynchronous for job process
|
||||
if ($asynchronous === true) {
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
$task->messageeventcron();
|
||||
Queue::assertPushed(TaskScheduler::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* cron_single.php
|
||||
*
|
||||
* @see workflow/engine/bin/cron.php
|
||||
* @see workflow/engine/bin/messageeventcron.php
|
||||
* @see workflow/engine/bin/timereventcron.php
|
||||
* @see workflow/engine/bin/ldapcron.php
|
||||
* @see workflow/engine/methods/setup/cron.php
|
||||
@@ -333,9 +332,8 @@ try {
|
||||
$task->ldapcron(in_array('+debug', $argv));
|
||||
break;
|
||||
case 'messageeventcron':
|
||||
$messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
|
||||
|
||||
$messageApplication->catchMessageEvent(true);
|
||||
$task = new Task($asynchronous, $sObject);
|
||||
$task->messageeventcron();
|
||||
break;
|
||||
case 'timereventcron':
|
||||
$timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
|
||||
|
||||
@@ -21,6 +21,7 @@ use ProcessMaker\BusinessModel\ActionsByEmail\ResponseReader;
|
||||
use ProcessMaker\BusinessModel\Cases as BmCases;
|
||||
use ProcessMaker\BusinessModel\Light\PushMessageAndroid;
|
||||
use ProcessMaker\BusinessModel\Light\PushMessageIOS;
|
||||
use ProcessMaker\BusinessModel\MessageApplication;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use Propel;
|
||||
@@ -238,7 +239,7 @@ class Task
|
||||
* Check if some task unassigned has enable the setting timeout and execute the trigger related
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.2/Tasks#Self-Service
|
||||
*/
|
||||
*/
|
||||
function executeCaseSelfService()
|
||||
{
|
||||
$job = function() {
|
||||
@@ -585,4 +586,16 @@ class Task
|
||||
};
|
||||
$this->runTask($job);
|
||||
}
|
||||
|
||||
/**
|
||||
* This execute message event cron.
|
||||
*/
|
||||
public function messageeventcron()
|
||||
{
|
||||
$job = function() {
|
||||
$messageApplication = new MessageApplication();
|
||||
$messageApplication->catchMessageEvent(true);
|
||||
};
|
||||
$this->runTask($job);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user