public function testfireUrl() { $schedulersJob = new SchedulersJob(); //test with invalid param $result = $schedulersJob->fireUrl(''); $this->assertEquals(false, $result); //test with valid param $result = $schedulersJob->fireUrl('https://suitecrm.com/'); $this->assertEquals(true, $result); }
public function testLocalServerPortNotUsed() { $url = $GLOBALS['sugar_config']['site_url'] . '/' . $this->_cron_test_file; $_SERVER['SERVER_PORT'] = '9090'; $sJob = new SchedulersJob(FALSE); $this->assertTrue($sJob->fireUrl($url)); }
/** * executes Scheduled job */ function fire() { if (empty($this->job)) { // only execute when valid $GLOBALS['log']->fatal('Scheduler tried to fire an empty job!!'); return false; } $exJob = explode('::', $this->job); if (is_array($exJob)) { // instantiate a new SchedulersJob object and prep it $trackerManager = TrackerManager::getInstance(); $trackerManager->pause(); $job = new SchedulersJob(); $job->scheduler_id = $this->id; $job->scheduler =& $this; $job->execute_time = $job->handleDateFormat('now'); $jobId = $job->save(); $trackerManager->unPause(); $job->retrieve($jobId); if ($exJob[0] == 'function') { $GLOBALS['log']->debug('----->Scheduler found a job of type FUNCTION'); require_once 'modules/Schedulers/_AddJobsHere.php'; $job->setJobFlag(1); $func = $exJob[1]; $GLOBALS['log']->debug('----->SchedulersJob firing ' . $func); $res = call_user_func($func); if ($res) { $job->setJobFlag(2); $job->finishJob(); return true; } else { $job->setJobFlag(3); return false; } } elseif ($exJob[0] == 'url') { if (function_exists('curl_init')) { $GLOBALS['log']->debug('----->SchedulersJob found a job of type URL'); $job->setJobFlag(1); $GLOBALS['log']->debug('----->SchedulersJob firing URL job: ' . $exJob[1]); if ($job->fireUrl($exJob[1])) { $job->setJobFlag(2); $job->finishJob(); return true; } else { $job->setJobFlag(3); return false; } } else { $job->setJobFlag(4); return false; } } } return false; }