/**
  * Assert that In Stock status is displayed on product page
  *
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     // TODO fix initialization url for frontend page
     $catalogProductView->init($product);
     $catalogProductView->open();
     \PHPUnit_Framework_Assert::assertEquals(self::STOCK_AVAILABILITY, $catalogProductView->getViewBlock()->stockAvailability(), 'Control \'' . self::STOCK_AVAILABILITY . '\' is not visible.');
 }
 /**
  * Verify product displaying on frontend
  *
  * @param FixtureInterface $product
  * @return array
  */
 protected function isNotDisplayingOnFrontendAssert(FixtureInterface $product)
 {
     $errors = [];
     // Check the product page is not available
     // TODO fix initialization url for frontend page
     $this->catalogProductView->init($product);
     $this->catalogProductView->open();
     $titleBlock = $this->catalogProductView->getTitleBlock();
     if ($titleBlock->getTitle() !== self::NOT_FOUND_MESSAGE) {
         $errors[] = '- the headline on the page does not match, the text should be -> "' . self::NOT_FOUND_MESSAGE . '".';
     }
     $this->cmsIndex->open();
     $this->cmsIndex->getSearchBlock()->search($product->getSku());
     if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product->getName())) {
         $errors[] = '- successful product search.';
     }
     $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0]['name'] : $this->category->getName();
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     while (!$isProductVisible && $this->catalogCategoryView->getToolbar()->nextPage()) {
         $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     }
     if ($isProductVisible) {
         $errors[] = '- product with name "{$product->getName()}" is found in this category.';
     }
     return $errors;
 }
 /**
  * Assert configurable product, corresponds to the product page
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductConfigurable $configurable
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductConfigurable $configurable)
 {
     //Open product view page
     $catalogProductView->init($configurable);
     $catalogProductView->open();
     //Process assertions
     $this->assertOnProductView($configurable, $catalogProductView);
 }
 /**
  * Assert that product rating is not displayed on frontend on product review
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @param Rating $productRating
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating)
 {
     $catalogProductView->init($product);
     $catalogProductView->open();
     $catalogProductView->getReviewSummaryBlock()->getAddReviewLink()->click();
     $reviewForm = $catalogProductView->getReviewFormBlock();
     \PHPUnit_Framework_Assert::assertFalse($reviewForm->isVisibleRating($productRating), 'Product rating "' . $productRating->getRatingCode() . '" is displayed.');
 }
 /**
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product)
 {
     //Open product view page
     $catalogProductView->init($product);
     $catalogProductView->open();
     //Process assertions
     $this->assertOnProductView($product, $catalogProductView);
 }
 /**
  * Assertion that tier prices are displayed correctly
  *
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     // TODO fix initialization url for frontend page
     //Open product view page
     $catalogProductView->init($product);
     $catalogProductView->open();
     //Process assertions
     $this->assertTierPrice($product, $catalogProductView);
 }
 /**
  * Assert that product rating is displayed on product review(frontend)
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @param ReviewInjectable|null $review [optional]
  * @param Rating|null $productRating [optional]
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, ReviewInjectable $review = null, Rating $productRating = null)
 {
     $catalogProductView->init($product);
     $catalogProductView->open();
     $catalogProductView->getReviewSummaryBlock()->getAddReviewLink()->click();
     $rating = $productRating ? $productRating : $review->getDataFieldConfig('ratings')['source']->getRatings()[0];
     $reviewForm = $catalogProductView->getReviewFormBlock();
     \PHPUnit_Framework_Assert::assertTrue($reviewForm->isVisibleRating($rating), 'Product rating "' . $rating->getRatingCode() . '" is not displayed.');
 }
 /**
  * Share wish list
  *
  * @param CustomerInjectable $customer
  * @param CatalogProductSimple $product
  * @param array $sharingInfo
  * @return void
  */
 public function test(CustomerInjectable $customer, CatalogProductSimple $product, $sharingInfo)
 {
     //Steps
     $this->loginCustomer($customer);
     $this->catalogProductView->init($product);
     $this->catalogProductView->open()->getViewBlock()->addToWishlist();
     $this->wishlistIndex->getWishlistBlock()->clickShareWishList();
     $this->wishlistShare->getSharingInfoForm()->fillForm($sharingInfo);
     $this->wishlistShare->getSharingInfoForm()->shareWishlist();
 }
 /**
  * Assert that displayed special price on product page equals passed from fixture
  *
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     $catalogProductView->init($product);
     $catalogProductView->open();
     $fields = $product->getData();
     $specialPrice = $catalogProductView->getViewBlock()->getProductPrice();
     $specialPrice = isset($specialPrice['price_special_price']) ? $specialPrice['price_special_price'] : null;
     if (isset($fields['special_price'])) {
         \PHPUnit_Framework_Assert::assertEquals($fields['special_price'], $specialPrice, 'Assert that displayed special price on product page NOT equals passed from fixture.');
     }
 }
 /**
  * Run create frontend product rating test
  *
  * @param CatalogProductSimple $product
  * @param ReviewInjectable $review
  * @return void
  */
 public function test(CatalogProductSimple $product, ReviewInjectable $review)
 {
     // Prepare for tear down
     $this->review = $review;
     // Steps
     $this->catalogProductView->init($product);
     $this->catalogProductView->open();
     $this->catalogProductView->getReviewSummaryBlock()->getAddReviewLink()->click();
     $reviewForm = $this->catalogProductView->getReviewFormBlock();
     $reviewForm->fill($review);
     $reviewForm->submit();
 }
 /**
  * Assert configurable product, corresponds to the product in the cart
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductConfigurable $configurable
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductConfigurable $configurable, CheckoutCart $checkoutCart)
 {
     //Add product to cart
     $catalogProductView->init($configurable);
     $catalogProductView->open();
     $configurableData = $configurable->getConfigurableAttributesData();
     if (!empty($configurableData)) {
         $configurableOption = $catalogProductView->getCustomOptionsBlock();
         foreach ($configurableData['attributes_data'] as $attribute) {
             $configurableOption->selectProductCustomOption(reset($attribute['options'])['name']);
         }
     }
     $catalogProductView->getViewBlock()->clickAddToCart();
     $this->assertOnShoppingCart($configurable, $checkoutCart);
 }
 /**
  * Assertion that the product is correctly displayed in cart
  *
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, CheckoutCart $checkoutCart)
 {
     // Add product to cart
     $catalogProductView->init($product);
     $catalogProductView->open();
     $productOptions = $product->getCustomOptions();
     if ($productOptions) {
         $customOption = $catalogProductView->getCustomOptionsBlock();
         $options = $customOption->getOptions();
         $key = $productOptions[0]['title'];
         $customOption->selectProductCustomOption(reset($options[$key]['value']));
     }
     $catalogProductView->getViewBlock()->clickAddToCart();
     // Check price
     $this->assertOnShoppingCart($product, $checkoutCart);
 }
 /**
  * Assertion that commodity options are displayed correctly
  *
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     $this->product = $product;
     // TODO fix initialization url for frontend page
     // Open product view page
     $catalogProductView->init($this->product);
     $catalogProductView->open();
     // Prepare data
     $customOptions = $catalogProductView->getCustomOptionsBlock()->getOptions();
     foreach ($customOptions as &$option) {
         unset($option['value']);
     }
     unset($option);
     $compareOptions = $this->prepareOptionArray($this->product->getCustomOptions());
     $customOptions = $this->dataSortByKey($customOptions);
     $compareOptions = $this->dataSortByKey($compareOptions);
     \PHPUnit_Framework_Assert::assertEquals($customOptions, $compareOptions, 'Incorrect display of custom product options on the product page.');
 }
 /**
  * 1. Creating product simple with custom tax product class
  * 2. Log In as customer
  * 3. Add product to shopping cart
  * 4. Estimate Shipping and Tax
  * 5. Implementation assert
  *
  * @param FixtureFactory $fixtureFactory
  * @param TaxRule $taxRule
  * @param CustomerAccountLogin $customerAccountLogin
  * @param CustomerAccountLogout $customerAccountLogout
  * @param CustomerInjectable $customer
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param AddressInjectable $address
  * @param array $shipping
  * @param TaxRule $initialTaxRule
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout, CustomerInjectable $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, AddressInjectable $address, array $shipping, TaxRule $initialTaxRule = null)
 {
     $this->initialTaxRule = $initialTaxRule;
     $this->taxRule = $taxRule;
     $this->checkoutCart = $checkoutCart;
     $this->shipping = $shipping;
     if ($this->initialTaxRule !== null) {
         $this->taxRuleCode = $this->taxRule->hasData('code') ? $this->taxRule->getCode() : $this->initialTaxRule->getCode();
     } else {
         $this->taxRuleCode = $this->taxRule->getCode();
     }
     // Creating simple product with custom tax class
     /** @var \Magento\Tax\Test\Fixture\TaxClass $taxProductClass */
     $taxProductClass = $taxRule->getDataFieldConfig('tax_product_class')['source']->getFixture()[0];
     $this->productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => '100_dollar_product_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]);
     $this->productSimple->persist();
     // Customer login
     $customerAccountLogout->open();
     $customerAccountLogin->open();
     $customerAccountLogin->getLoginBlock()->login($customer);
     // Clearing shopping cart and adding product to shopping cart
     $checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $catalogProductView->init($this->productSimple);
     $catalogProductView->open();
     $catalogProductView->getViewBlock()->clickAddToCart();
     // Estimate Shipping and Tax
     $checkoutCart->getShippingBlock()->openEstimateShippingAndTax();
     $checkoutCart->getShippingBlock()->fill($address);
     $checkoutCart->getShippingBlock()->clickGetQuote();
     $checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
     $this->assert();
 }