2 /*********************************************************************************
3 * By installing or using this file, you are confirming on behalf of the entity
4 * subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
5 * the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
6 * http://www.sugarcrm.com/master-subscription-agreement
8 * If Company is not bound by the MSA, then by installing or using this file
9 * you are agreeing unconditionally that Company will be bound by the MSA and
10 * certifying that you have authority to bind Company accordingly.
12 * Copyright (C) 2004-2013 SugarCRM Inc. All rights reserved.
13 ********************************************************************************/
15 require_once 'modules/SchedulersJobs/SchedulersJob.php';
18 * Bug #56537 : Schedule Jobs don't work with classes
22 class Bug56573Test extends Sugar_PHPUnit_Framework_TestCase
29 public function setUp()
32 SugarTestHelper::setUp('current_user');
35 public function tearDown()
37 if (!empty($this->id)) {
38 $job = new SchedulersJob();
39 $job->mark_deleted($this->id);
41 SugarTestHelper::tearDown();
44 protected function execJob($name, $data)
46 require_once('include/SugarQueue/SugarJobQueue.php');
48 $job = new SchedulersJob();
49 $job->name = "Bug56573Test Alert Job - '{$name}'";
51 $job->target = "class::Bug56573TestJob";
52 $job->assigned_user_id = $GLOBALS['current_user']->id;
53 $jq = new SugarJobQueue();
60 public static function provider()
63 array('Success', true, SchedulersJob::JOB_SUCCESS),
64 array('Failure', false, SchedulersJob::JOB_FAILURE)
69 * Job executed or failed
70 * @dataProvider provider
73 public function testJob($name, $result, $resolution)
75 $job = $this->execJob($name, $result);
76 $this->assertEquals($resolution, $job->resolution, "Wrong resolution");
77 $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $job->status, "Wrong status");
81 class Bug56573TestJob implements RunnableSchedulerJob
84 public function run($data)
89 public function setJob(SchedulersJob $job)