/**
  * Assertion that the product is correctly displayed in cart
  *
  * @param Browser $browser
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param ConfigurableProductInjectable $product
  * @return void
  */
 public function processAssert(Browser $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, ConfigurableProductInjectable $product)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutData = $product->getCheckoutData();
     $price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
     \PHPUnit_Framework_Assert::assertEquals($checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.');
 }
 /**
  * Run Delete used in configurable product attribute test
  *
  * @param ConfigurableProductInjectable $product
  * @return array
  */
 public function test(ConfigurableProductInjectable $product)
 {
     // Precondition
     $product->persist();
     /** @var CatalogProductAttribute $attribute */
     $attribute = $product->getDataFieldConfig('configurable_attributes_data')['source']->getAttributes()['attribute_0'];
     // Steps
     $this->attributeIndex->open();
     $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]);
     $this->attributeNew->getPageActions()->delete();
     return ['attribute' => $attribute];
 }
 /**
  * Assert that child products generated during configurable product are present in products grid
  *
  * @param CatalogProductIndex $productGrid
  * @param ConfigurableProductInjectable $product
  * @return void
  */
 public function processAssert(CatalogProductIndex $productGrid, ConfigurableProductInjectable $product)
 {
     $configurableAttributesData = $product->getConfigurableAttributesData();
     $productType = $product->getIsVirtual() ? 'Virtual Product' : 'Simple Product';
     $errors = [];
     $productGrid->open();
     foreach ($configurableAttributesData['matrix'] as $variation) {
         $filter = ['name' => $variation['name'], 'type' => $productType, 'sku' => $variation['sku'], 'visibility' => self::NOT_VISIBLE_INDIVIDUALLY];
         if (!$productGrid->getProductGrid()->isRowVisible($filter)) {
             $errors[] = sprintf('Child product with name: "%s" and sku:"%s" is absent in grid.', $filter['name'], $filter['sku']);
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode($errors, ' '));
 }
 /**
  * Assert that products generated during configurable product creation - are not visible on frontend(by default).
  *
  * @param CatalogSearchResult $catalogSearchResult
  * @param CmsIndex $cmsIndex
  * @param ConfigurableProductInjectable $product
  * @return void
  */
 public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, ConfigurableProductInjectable $product)
 {
     $configurableAttributesData = $product->getConfigurableAttributesData();
     $errors = [];
     $cmsIndex->open();
     foreach ($configurableAttributesData['matrix'] as $variation) {
         $cmsIndex->getSearchBlock()->search($variation['sku']);
         $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($variation['name']);
         while (!$isVisibleProduct && $catalogSearchResult->getBottomToolbar()->nextPage()) {
             $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName());
         }
         if ($isVisibleProduct) {
             $errors[] = sprintf("\nChild product with sku: \"%s\" is visible on frontend(by default).", $variation['sku']);
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(' ', $errors));
 }
 /**
  * Verify displayed product short description on product page(front-end) equals passed from fixture
  *
  * @return string|null
  */
 protected function verifyShortDescription()
 {
     $fixtureProductShortDescription = $this->product->getShortDescription();
     $formProductShortDescription = $this->productView->getProductShortDescription();
     if ($fixtureProductShortDescription == $formProductShortDescription) {
         return null;
     }
     return "Displayed product short description on product page(front-end) not equals passed from fixture. " . "Actual: {$formProductShortDescription}, expected: {$fixtureProductShortDescription}.";
 }