public function testGetAllCronJobsIgnoreActive() { $this->assertArrayCount(0, $this->object->getAllJobs()); $this->assertInstanceOf('Enlight_Components_Cron_Adapter', $this->object->addJob($this->job)); $this->job->setAction('foo'); $this->job->setActive(false); $this->assertInstanceOf('Enlight_Components_Cron_Adapter', $this->object->addJob($this->job)); $this->assertArrayCount(1, $this->object->getAllJobs()); $this->assertArrayCount(2, $this->object->getAllJobs(true)); }
/** * Runs a job by handing it over to * * @param Enlight_Components_Cron_Job $job * @return Enlight_Event_EventArgs * @throw Enlight_Exception */ public function runJob(Enlight_Components_Cron_Job $job) { // Fix cron action name $action = $job->getAction(); if (strpos($action, 'Shopware_') !== 0) { $action = str_replace(' ', '', ucwords(str_replace('_', ' ', $job->getAction()))); $job->setAction('Shopware_CronJob_' . $action); } try { if ($this->adapter->startJob($job)) { $jobArgs = new $this->eventArgsClass(array('subject' => $this, 'job' => $job)); $jobArgs->setReturn($job->getData()); $jobArgs = $this->eventManager->notifyUntil($job->getAction(), $jobArgs); if ($jobArgs !== null) { $job->setData($jobArgs->getReturn()); $this->adapter->updateJob($job); } $this->endJob($job); return $jobArgs; } } catch (Exception $e) { $job->setData(array('error' => $e->getMessage())); $this->disableJob($job); throw $e; } }
/** * @todo Implement testSetAction(). */ public function testSetAction() { $this->assertInstanceOf('Enlight_Components_Cron_Job', $this->job->setAction('test_action')); $this->assertEquals('test_action', $this->job->getAction()); }