/** * Retrieve all available import jobs by traversing trough registered * import jobs and checking "isEnabled". * * @return array */ protected function getAvailableJobs() { $availableJobs = array(); $registeredJobs = ImportJob::getRegisteredJobs(); foreach ($registeredJobs as $registeredJob) { $jobInstance = $this->objectManager->get($registeredJob['className']); if ($jobInstance instanceof ImportJobInterface && $jobInstance->isEnabled()) { $availableJobs[$registeredJob['className']] = $GLOBALS['LANG']->sL($registeredJob['title']); } } return $availableJobs; }
/** * @test */ public function classCanBeRegistered() { $importJobInstance = new ImportJob(); $jobs = array(); $this->assertEquals($importJobInstance->getRegisteredJobs(), $jobs); // Add job #1 $jobs[] = array('className' => 'Class 1', 'title' => 'Some title', 'description' => ''); $importJobInstance->register('Class 1', 'Some title', ''); $this->assertEquals($importJobInstance->getRegisteredJobs(), $jobs); // Add job #2 $jobs[] = array('className' => 'Class 2', 'title' => '', 'description' => 'Some description'); $importJobInstance->register('Class 2', '', 'Some description'); $this->assertEquals($importJobInstance->getRegisteredJobs(), $jobs); }