/** * {@inheritdoc} */ public function getEditTemplate(JobInstance $jobInstance) { $jobName = $jobInstance->getJobName(); if (isset($this->jobTemplates[$jobName]) && isset($this->jobTemplates[$jobName]['templates']['edit'])) { return $this->jobTemplates[$jobName]['templates']['edit']; } return sprintf(self::DEFAULT_EDIT_TEMPLATE, ucfirst($jobInstance->getType())); }
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":";"}']); }
function it_adds_a_violation_if_job_instance_has_an_unknown_type($jobRegistry, $context, JobInstanceConstraint $constraint, JobInstance $jobInstance, ConstraintViolationBuilderInterface $violation) { $jobInstance->getJobName()->willReturn(null); $jobRegistry->get(null)->willThrow(new UndefinedJobException('The job "" is not registered')); $jobInstance->getType()->willReturn('import'); $context->buildViolation($constraint->message, ['%job_type%' => 'import'])->shouldBeCalled()->willReturn($violation); $violation->atPath($constraint->property)->shouldBeCalled()->willReturn($violation); $violation->addViolation()->shouldBeCalled(); $this->validate($jobInstance, $constraint); }
/** * Get a registered job definition from a JobInstance * * @param JobInstance $jobInstance * * @throws \LogicException * @return JobInterface */ public function getJob(JobInstance $jobInstance) { if ($connector = $this->getConnector($jobInstance->getConnector(), $jobInstance->getType())) { if ($job = $this->getConnectorJob($connector, $jobInstance->getAlias())) { $job->setConfiguration($jobInstance->getRawConfiguration()); $jobInstance->setJob($job); return $job; } } return null; }
function it_generates_default_export_job_template(JobInstance $jobInstance) { $jobInstance->getJobName()->willReturn('an_unknown_job'); $jobInstance->getType()->willReturn('export'); $expectedJobTemplate = sprintf(JobTemplateProvider::DEFAULT_CREATE_TEMPLATE, 'Export'); $this->getCreateTemplate($jobInstance)->shouldReturn($expectedJobTemplate); $expectedJobTemplate = sprintf(JobTemplateProvider::DEFAULT_SHOW_TEMPLATE, 'Export'); $this->getShowTemplate($jobInstance)->shouldReturn($expectedJobTemplate); $expectedJobTemplate = sprintf(JobTemplateProvider::DEFAULT_EDIT_TEMPLATE, 'Export'); $this->getEditTemplate($jobInstance)->shouldReturn($expectedJobTemplate); }
function it_provides_a_configured_job(JobInstance $jobInstance, $job) { $rawConfiguration = ['my raw conf']; $jobInstance->getConnector()->willReturn('Data fixtures'); $jobInstance->getType()->willReturn('fixtures'); $jobInstance->getAlias()->willReturn('fixtures_category_csv'); $jobInstance->getRawConfiguration()->willReturn($rawConfiguration); $job->setConfiguration($rawConfiguration)->shouldBeCalled(); $jobInstance->setJob($job)->shouldBeCalled(); $this->getJob($jobInstance)->shouldReturn($job); }
/** * @param JobInstance $job * * @When /^I launch the ("([^"]*)" (import|export) job)$/ */ public function iLaunchTheExportJob(JobInstance $job) { $jobType = ucfirst($job->getType()); $this->getNavigationContext()->openPage(sprintf('%s launch', $jobType), ['id' => $job->getId()]); }
/** * @param JobInstance $job * * @Given /^I should be on the ("([^"]*)" (import|export) job) page$/ */ public function iShouldBeOnTheJobPage(JobInstance $job) { $jobPage = sprintf('%s show', ucfirst($job->getType())); $expectedAddress = $this->getPage($jobPage)->getUrl(['id' => $job->getId()]); $this->assertAddress($expectedAddress); }
/** * @param string $action * @param JobInstance $job * * @return \Behat\Behat\Context\Step\Then * * @When /^I should not be able to (launch|edit) the ("([^"]*)" (export|import) job)$/ */ public function iShouldNotBeAbleToAccessTheJob($action, JobInstance $job) { $this->currentPage = sprintf("%s %s", ucfirst($job->getType()), $action); $page = $this->getCurrentPage()->open(['id' => $job->getId()]); return new Step\Then('I should see "403 Forbidden"'); }
/** * {@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; }