コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $variantRepository = $this->variantRepository;
     $builder->add('variant', 'sylius_entity_to_identifier', array('label' => 'sylius.form.action.add_product_configuration.variant', 'class' => $this->variantRepository->getClassName(), 'query_builder' => function () use($variantRepository) {
         return $variantRepository->getFormQueryBuilder();
     }, 'constraints' => array(new NotBlank(), new Type(array('type' => 'numeric')))))->add('quantity', 'integer', array('label' => 'sylius.form.action.add_product_configuration.quantity', 'empty_data' => 1, 'constraints' => array(new NotBlank(), new Type(array('type' => 'numeric')))))->add('price', 'sylius_money', array('label' => 'sylius.form.action.add_product_configuration.price', 'empty_data' => 0, 'constraints' => array(new NotBlank(), new Type(array('type' => 'numeric')))));
 }
コード例 #2
0
ファイル: ProductContext.php プロジェクト: Mozan/Sylius
 /**
  * @Transform /^"([^"]+)" variant of product "([^"]+)"$/
  */
 public function getProductVariantByNameAndProduct($variantName, $productName)
 {
     $product = $this->getProductByName($productName);
     $productVariant = $this->productVariantRepository->findOneBy(['presentation' => $variantName, 'object' => $product]);
     if (null === $productVariant) {
         throw new \InvalidArgumentException(sprintf('Product variant with name "%s" of product "%s" does not exist', $variantName, $productName));
     }
     return $productVariant;
 }
コード例 #3
0
ファイル: ProductContext.php プロジェクト: okwinza/Sylius
 /**
  * @Then /^there should be no variants of (this product) in the product catalog$/
  */
 public function thereAreNoVariants(ProductInterface $product)
 {
     expect($this->productVariantRepository->findBy(['object' => $product]))->toBe([]);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('variant', 'sylius_entity_to_identifier', ['label' => 'sylius.form.action.add_product_configuration.variant', 'class' => $this->variantRepository->getClassName(), 'query_builder' => function () {
         return $this->variantRepository->getFormQueryBuilder();
     }, 'constraints' => [new NotBlank(), new Type(['type' => 'numeric'])]])->add('count', 'integer', ['label' => 'sylius.form.rule.cart_quantity_configuration.count', 'constraints' => [new NotBlank(), new Type(['type' => 'numeric'])]])->add('equal', 'checkbox', ['label' => 'sylius.form.rule.cart_quantity_configuration.equal', 'constraints' => [new Type(['type' => 'bool'])]])->add('exclude', 'checkbox', ['label' => 'sylius.form.rule.contains_product_configuration.exclude']);
 }
コード例 #5
0
 /**
  * @Transform /^"([^"]+)" product variant$/
  * @Transform /^"([^"]+)" variant$/
  */
 public function getProductVariantByName($name)
 {
     $productVariant = $this->productVariantRepository->findOneBy(['name' => $name]);
     Assert::notNull($productVariant, sprintf('There is no product variant for "%s" name', $name));
     return $productVariant;
 }
コード例 #6
0
 /**
  * @Then /^there should be no variants of (this product) in the product catalog$/
  */
 public function thereAreNoVariants(ProductInterface $product)
 {
     $variants = $this->productVariantRepository->findBy(['object' => $product]);
     Assert::same($variants, []);
 }
コード例 #7
0
ファイル: ProductContextSpec.php プロジェクト: Mozan/Sylius
 function it_throws_element_not_found_exception_if_product_variant_has_not_been_found(ProductRepositoryInterface $productRepository, ProductVariantRepositoryInterface $productVariantRepository, ProductInterface $product)
 {
     $productRepository->findOneByName('T-Shirt')->willReturn($product);
     $productVariantRepository->findOneBy(['presentation' => 'Han Solo T-Shirt', 'object' => $product])->willReturn(null);
     $this->shouldThrow(\InvalidArgumentException::class)->during('getProductVariantByNameAndProduct', ['Han Solo T-Shirt', 'T-Shirt']);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('variant', 'sylius_product_variant_from_identifier', ['label' => 'sylius.form.action.add_product_configuration.variant', 'class' => $this->variantRepository->getClassName(), 'constraints' => [new NotBlank(), new Type(['type' => 'numeric'])]])->add('quantity', 'integer', ['label' => 'sylius.form.action.add_product_configuration.quantity', 'empty_data' => 1, 'constraints' => [new NotBlank(), new Type(['type' => 'numeric'])]])->add('price', 'sylius_money', ['label' => 'sylius.form.action.add_product_configuration.price', 'empty_data' => 0, 'constraints' => [new NotBlank(), new Type(['type' => 'numeric'])]]);
 }
コード例 #9
0
 function it_throws_an_exception_if_variants_of_the_product_still_exist(SharedStorageInterface $sharedStorage, ProductVariantRepositoryInterface $productVariantRepository, ProductInterface $product, VariantInterface $variant)
 {
     $sharedStorage->get('deleted_product')->willReturn($product);
     $productVariantRepository->findBy(['object' => $product])->willReturn([$variant]);
     $this->shouldThrow(FailureException::class)->during('thereAreNoVariants', [$product]);
 }