Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 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']);
 }