function it_sets_invalid_values_to_attributes($validator, $productUpdater, AttributeInterface $attribute, AttributeRepositoryInterface $attributeRepository, ProductInterface $product, ConstraintViolationListInterface $violations, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration) { $stepExecution->getJobExecution()->willReturn($jobExecution); $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration); $values = ['categories' => [['scope' => null, 'locale' => null, 'data' => ['office', 'bedroom']]]]; $normalizedValues = addslashes(json_encode($values)); $jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => ['normalized_values' => $normalizedValues, 'ui_locale' => 'fr_FR', 'attribute_locale' => 'en_US']])); $validator->validate($product)->willReturn($violations); $violation = new ConstraintViolation('error2', 'spec', [], '', '', $product); $violations = new ConstraintViolationList([$violation, $violation]); $validator->validate($product)->willReturn($violations); $attributeRepository->findOneByIdentifier('categories')->willReturn($attribute); $product->isAttributeEditable($attribute)->willReturn(true); $productUpdater->update($product, $values)->shouldBeCalled(); $this->setStepExecution($stepExecution); $stepExecution->addWarning(Argument::cetera())->shouldBeCalled(); $stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled(); $this->process($product); }
function it_throws_an_exception_if_no_config_is_found(JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, StepExecution $stepExecution) { $this->setStepExecution($stepExecution); $stepExecution->getJobExecution()->willReturn($jobExecution); $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn(null); $this->shouldThrow('\\Doctrine\\ORM\\EntityNotFoundException')->during('read'); }
function it_adds_invalid_values_to_product($propertyAdder, $validator, ProductInterface $product, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration) { $violation = new ConstraintViolation('error2', 'spec', [], '', '', $product); $violations = new ConstraintViolationList([$violation, $violation]); $validator->validate($product)->willReturn($violations); $stepExecution->getJobExecution()->willReturn($jobExecution); $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration); $jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => [['field' => 'categories', 'value' => ['office', 'bedroom']]]])); $propertyAdder->addData($product, 'categories', ['office', 'bedroom'])->shouldBeCalled(); $stepExecution->addWarning(Argument::cetera())->shouldBeCalled(); $stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled(); $this->setStepExecution($stepExecution); $this->process($product); }
/** * Save the job configuration * * @param string $configuration */ protected function setJobConfiguration($configuration) { $jobExecution = $this->stepExecution->getJobExecution(); $massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]); $massEditJobConf->setConfiguration($configuration); $this->jobConfigurationSaver->save($massEditJobConf); }
function it_adds_invalid_values_to_product($groupRepository, $validator, $templateUpdater, GroupInterface $variantGroup, ProductInterface $product, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration, ProductTemplateInterface $productTemplate) { $violation = new ConstraintViolation('error2', 'spec', [], '', '', $product); $violations = new ConstraintViolationList([$violation, $violation]); $validator->validate($product)->willReturn($violations); $stepExecution->getJobExecution()->willReturn($jobExecution); $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration); $jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => ['field' => 'variant_group', 'value' => 'variant_group_code']])); $groupRepository->findOneByIdentifier('variant_group_code')->willReturn($variantGroup); $product->getVariantGroup()->willReturn(null); $variantGroup->addProduct($product)->shouldBeCalled(); $variantGroup->getProductTemplate()->willReturn($productTemplate); $templateUpdater->update($variantGroup->getProductTemplate(), [$product]); $stepExecution->addWarning(Argument::cetera())->shouldBeCalled(); $stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled(); $this->setStepExecution($stepExecution); $this->process($product); }
function it_sets_invalid_values_to_attributes($validator, $propertySetter, FamilyInterface $family, AttributeInterface $attribute, AttributeRepository $attributeRepository, ProductInterface $product, ConstraintViolationListInterface $violations, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration) { $stepExecution->getJobExecution()->willReturn($jobExecution); $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration); $jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => [['field' => 'categories', 'value' => ['office', 'bedroom'], 'options' => []]]])); $validator->validate($product)->willReturn($violations); $violation = new ConstraintViolation('error2', 'spec', [], '', '', $product); $violations = new ConstraintViolationList([$violation, $violation]); $validator->validate($product)->willReturn($violations); $attributeRepository->findOneBy(['code' => 'categories'])->willReturn($attribute); $family->hasAttribute($attribute)->willReturn(true); $product->getFamily()->willReturn($family); $propertySetter->setData($product, 'categories', ['office', 'bedroom'], [])->shouldBeCalled(); $this->setStepExecution($stepExecution); $stepExecution->addWarning(Argument::cetera())->shouldBeCalled(); $stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled(); $this->process($product); }
/** * Return the job configuration * * @throws EntityNotFoundException * * @return array */ protected function getJobConfiguration() { $jobExecution = $this->stepExecution->getJobExecution(); $massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]); if (null === $massEditJobConf) { throw new EntityNotFoundException(sprintf('No JobConfiguration found for jobExecution with id %s', $jobExecution->getId())); } return json_decode(stripcslashes($massEditJobConf->getConfiguration()), true); }
/** * Return the job configuration * * @return array */ protected function getJobConfiguration() { $jobExecution = $this->stepExecution->getJobExecution(); $massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]); return json_decode(stripcslashes($massEditJobConf->getConfiguration()), true); }