Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function getName()
 {
     if (null === $this->option) {
         throw new \BadMethodCallException('The option have not been created yet so you cannot access proxy methods.');
     }
     return $this->option->getName();
 }
 function it_generates_variants_for_every_possible_permutation_of_an_objects_options_and_option_values(ProductInterface $productVariable, ProductOptionInterface $colorOption, ProductOptionInterface $sizeOption, ProductOptionValueInterface $blackColor, ProductOptionValueInterface $largeSize, ProductOptionValueInterface $mediumSize, ProductOptionValueInterface $redColor, ProductOptionValueInterface $smallSize, ProductOptionValueInterface $whiteColor, ProductVariantFactoryInterface $productVariantFactory, ProductVariantInterface $permutationVariant)
 {
     $productVariable->hasOptions()->willReturn(true);
     $productVariable->getOptions()->willReturn([$colorOption, $sizeOption]);
     $colorOption->getValues()->willReturn([$blackColor, $whiteColor, $redColor]);
     $sizeOption->getValues()->willReturn([$smallSize, $mediumSize, $largeSize]);
     $blackColor->getId()->willReturn('black1');
     $whiteColor->getId()->willReturn('white2');
     $redColor->getId()->willReturn('red3');
     $smallSize->getId()->willReturn('small4');
     $mediumSize->getId()->willReturn('medium5');
     $largeSize->getId()->willReturn('large6');
     $productVariantFactory->createForProduct($productVariable)->willReturn($permutationVariant);
     $permutationVariant->addOptionValue(Argument::type(ProductOptionValueInterface::class))->shouldBeCalled();
     $productVariable->addVariant($permutationVariant)->shouldBeCalled();
     $this->generate($productVariable);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function addToCartWithOption(ProductOptionInterface $option, $optionValue)
 {
     $select = $this->getDocument()->find('css', sprintf('select#sylius_cart_item_variant_%s', $option->getCode()));
     $this->getDocument()->selectFieldOption($select->getAttribute('name'), $optionValue);
     $this->getDocument()->pressButton('Add to cart');
 }
 /**
  * @Then /^(this product option) should still be named "([^"]+)"$/
  * @Then /^(this product option) name should be "([^"]+)"$/
  */
 public function thisProductOptionNameShouldStillBe(ProductOptionInterface $productOption, $productOptionName)
 {
     $this->iBrowseProductOptions();
     Assert::true($this->indexPage->isSingleResourceOnPage(['code' => $productOption->getCode(), 'name' => $productOptionName]), sprintf('Product option name %s has not been assigned properly.', $productOptionName));
 }
Пример #5
0
 /**
  * @Given /^(this product option) has(?:| also) the "([^"]+)" option value with code "([^"]+)"$/
  */
 public function thisProductOptionHasTheOptionValueWithCode(ProductOptionInterface $productOption, $productOptionValueName, $productOptionValueCode)
 {
     $productOptionValue = $this->createProductOptionValue($productOptionValueName, $productOptionValueCode);
     $productOption->addValue($productOptionValue);
     $this->objectManager->flush();
 }