function it_does_not_add_violation_if_conflictual_product_and_validated_one_are_the_same($productRepository, ProductInterface $product, $context)
 {
     $constraint = new ProductUnique(array('property' => 'name', 'message' => 'Product with given name already exists'));
     $product->getName()->willReturn('iPhone');
     $productRepository->findOneBy(array('name' => 'iPhone'))->shouldBeCalled()->willReturn($product);
     $context->addViolationAt(Argument::any())->shouldNotBeCalled();
     $this->validate($product, $constraint);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function hasProductOutOfStockValidationMessage(ProductInterface $product)
 {
     $message = sprintf('%s does not have sufficient stock.', $product->getName());
     if (!$this->hasElement('validation-errors')) {
         return false;
     }
     return $this->getElement('validation-errors')->getText() === $message;
 }
예제 #3
0
 /**
  * @Given /^(this product) should have ([^"]+) "([^"]+)"$/
  */
 public function thisItemShouldHaveOptionValue(ProductInterface $product, $optionName, $optionValue)
 {
     Assert::true($this->summaryPage->hasItemWithOptionValue($product->getName(), $optionName, $optionValue), sprintf('Product in cart "%s" should have option %s with value %s, but it has not.', $product->getName(), $optionName, $optionValue));
 }