id = null; SugarTestHelper::setUp('current_user'); } public function tearDown() { if (!empty($this->id)) { $job = new SchedulersJob(); $job->mark_deleted($this->id); } SugarTestHelper::tearDown(); } protected function execJob($name, $data) { require_once('include/SugarQueue/SugarJobQueue.php'); $job = new SchedulersJob(); $job->name = "Bug56573Test Alert Job - '{$name}'"; $job->data = $data; $job->target = "class::Bug56573TestJob"; $job->assigned_user_id = $GLOBALS['current_user']->id; $jq = new SugarJobQueue(); $jq->submitJob($job); $this->id = $job->id; $job->runJob(); return $job; } public static function provider() { return array( array('Success', true, SchedulersJob::JOB_SUCCESS), array('Failure', false, SchedulersJob::JOB_FAILURE) ); } /** * Job executed or failed * @dataProvider provider * @group 56537 */ public function testJob($name, $result, $resolution) { $job = $this->execJob($name, $result); $this->assertEquals($resolution, $job->resolution, "Wrong resolution"); $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $job->status, "Wrong status"); } } class Bug56573TestJob implements RunnableSchedulerJob { public function run($data) { return $data; } public function setJob(SchedulersJob $job) { $this->job = $job; } }