/** * {@inheritdoc} */ public function isThereProduct(ProductInterface $product) { if (!($table = $this->getDocument()->find('css', 'table'))) { return false; } $row = $this->tableManipulator->getRowWithFields($table, ['id' => $product->getId()]); return null === $row; }
/** * @When /^I delete the ("[^"]+" product)$/ * @When /^I try to delete the ("([^"]+)" product)$/ */ public function iDeleteTheProduct(ProductInterface $product) { try { $this->sharedStorage->set('product_id', $product->getId()); $this->productRepository->remove($product); } catch (DBALException $exception) { $this->sharedStorage->set('last_exception', $exception); } }
/** * @Then the :variant variant of :product product should have :amount items on hold */ public function theVariantOfProductShouldHaveItemsOnHold(ProductVariantInterface $variant, ProductInterface $product, $amount) { $this->indexPage->open(['productId' => $product->getId()]); Assert::same($amount, $this->indexPage->getOnHoldQuantityFor($variant), sprintf('Unexpected on hold quantity for "%s" variant. It should be "%s" but is "%s"', $variant->getName(), $amount, $this->indexPage->getOnHandQuantityFor($variant))); }
/** * @Then /^(this product) main taxon should be "([^"]+)"$/ */ public function thisProductMainTaxonShouldBe(ProductInterface $product, $taxonName) { /** @var UpdatePageInterface $currentPage */ $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->updateSimpleProductPage, $this->updateConfigurableProductPage], $this->sharedStorage->get('product')); $currentPage->open(['id' => $product->getId()]); Assert::true($this->updateConfigurableProductPage->isMainTaxonChosen($taxonName), sprintf('The main taxon %s should be chosen, but it does not.', $taxonName)); }
/** * @Then /^(this product) should no longer have price for channel "([^"]+)"$/ */ public function thisProductShouldNoLongerHavePriceForChannel(ProductInterface $product, $channelName) { $this->updateSimpleProductPage->open(['id' => $product->getId()]); try { $this->updateSimpleProductPage->getPriceForChannel($channelName); } catch (ElementNotFoundException $exception) { return; } throw new \Exception(sprintf('Product "%s" should not have price defined for channel "%s".', $product->getName(), $channelName)); }
/** * @When /^I (?:|want to )view all variants of (this product)$/ * @When /^I view(?:| all) variants of the (product "[^"]+")$/ */ public function iWantToViewAllVariantsOfThisProduct(ProductInterface $product) { $this->indexPage->open(['productId' => $product->getId()]); }
/** * @When /^I want to generate new variants for (this product)$/ */ public function iWantToGenerateNewVariantsForThisProduct(ProductInterface $product) { $this->generatePage->open(['productId' => $product->getId()]); }
function it_tries_to_delete_a_product_that_does_not_exist(SharedStorageInterface $sharedStorage, RepositoryInterface $productRepository, ProductInterface $product) { $product->getId()->willReturn(1); $productRepository->find(1)->willReturn(null); $sharedStorage->set('deleted_product', $product)->shouldBeCalled(); $productRepository->remove($product)->willThrow(DBALException::class); $sharedStorage->set('last_exception', Argument::type(DBALException::class))->shouldBeCalled(); $this->iDeleteTheProduct($product); }
/** * @When I delete the :product product */ public function iDeleteProduct(ProductInterface $product) { $this->adminProductShowPage->open(['id' => $product->getId()]); $this->adminProductShowPage->deleteProduct(); $this->sharedStorage->set('product', $product); }