function it_normalizes_job_instance(JobInstance $jobinstance) { $jobinstance->getCode()->willReturn('product_export'); $jobinstance->getLabel()->willReturn('Product export'); $jobinstance->getConnector()->willReturn('myconnector'); $jobinstance->getType()->willReturn('EXPORT'); $jobinstance->getRawParameters()->willReturn(['delimiter' => ';']); $this->normalize($jobinstance)->shouldReturn(['code' => 'product_export', 'label' => 'Product export', 'connector' => 'myconnector', 'type' => 'EXPORT', 'configuration' => '{"delimiter":";"}']); }
/** * To string * @return string */ public function __toString() { $startTime = self::formatDate($this->startTime); $endTime = self::formatDate($this->endTime); $updatedTime = self::formatDate($this->updatedTime); $jobInstanceCode = $this->jobInstance != null ? $this->jobInstance->getCode() : ''; $message = "startTime=%s, endTime=%s, updatedTime=%s, status=%d, exitStatus=%s, exitDescription=[%s], job=[%s]"; return sprintf($message, $startTime, $endTime, $updatedTime, $this->status, $this->exitStatus, $this->exitDescription, $jobInstanceCode); }
/** * Launch a job * TODO: refactor all this * * @param JobInstance $job */ protected function launchJob(JobInstance $job) { $app = new Application($this->container->get('kernel')); $cmd = new BatchCommand(); $cmd->setContainer($this->container); $cmd->setApplication($app); $cmd->run(new ArrayInput(['command' => 'akeneo:batch:job', 'code' => $job->getCode(), '--no-debug' => true, '--no-log' => true, '-v' => true]), new ConsoleOutput()); $execution = $this->getJobExecution($job); if (!$this->executionComplete($execution)) { throw new JobExecutionException($execution); } }
function it_configures_job_instances_with_several_replacement_paths(JobInstance $instance) { $myFilePath = __FILE__; $myInstallerPath = dirname($myFilePath); $myFileName = str_replace($myInstallerPath, '', $myFilePath); $myReplacementFileCommunity = $myFilePath; $myReplacementFileEnterprise = $myFilePath; $replacementPaths = [$myFileName => [$myReplacementFileCommunity, $myReplacementFileEnterprise]]; $instance->getCode()->willReturn('my_original_code'); $instance->getRawParameters()->willReturn(['filePath' => $myFileName]); $instance->setRawParameters(['filePath' => $myReplacementFileCommunity])->shouldBeCalled(); $instance->setCode('my_original_code0')->shouldBeCalled(); $instance->getRawParameters()->willReturn(['filePath' => $myFileName]); $instance->setRawParameters(['filePath' => $myReplacementFileEnterprise])->shouldBeCalled(); $instance->setCode('my_original_code1')->shouldBeCalled(); $configuredInstances = $this->configureJobInstancesWithReplacementPaths([$instance], $replacementPaths); $configuredInstances->shouldHaveCount(2); }
/** * {@inheritdoc} * * @param JobInstance $object */ public function normalize($object, $format = null, array $context = []) { $results = ['code' => $object->getCode(), 'label' => $object->getLabel(), 'connector' => $object->getConnector(), 'type' => $object->getType(), 'configuration' => $this->normalizeConfiguration($object)]; return $results; }