/**
  * Assert that product rating is not displayed on frontend on product review
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @param Rating $productRating
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getReviewSummary()->getAddReviewLink()->click();
     $reviewForm = $catalogProductView->getReviewFormBlock();
     \PHPUnit_Framework_Assert::assertFalse($reviewForm->isVisibleRating($productRating), 'Product rating "' . $productRating->getRatingCode() . '" is displayed.');
 }
 /**
  * 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.');
 }
 /**
  * Assert that product rating is not displayed on frontend on product review
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @param Rating $productRating
  * @param Browser $browser
  * @param ReviewInjectable $review
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, Browser $browser, ReviewInjectable $review = null)
 {
     $product = $review === null ? $product : $review->getDataFieldConfig('entity_id')['source']->getEntity();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getReviewSummary()->getAddReviewLink()->click();
     $reviewForm = $catalogProductView->getReviewFormBlock();
     \PHPUnit_Framework_Assert::assertFalse($reviewForm->isVisibleRating($productRating), 'Product rating "' . $productRating->getRatingCode() . '" is displayed.');
 }
 /**
  * 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.');
 }
 /**
  * Assert that product rating is displayed on product review(frontend)
  *
  * @param CatalogProductView $catalogProductView
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param Review|null $review [optional]
  * @param Rating|null $productRating [optional]
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, BrowserInterface $browser, CatalogProductSimple $product, Review $review = null, Rating $productRating = null)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewSummaryBlock = $catalogProductView->getReviewSummary();
     if ($reviewSummaryBlock->isVisible()) {
         $reviewSummaryBlock->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.');
 }
 /**
  * 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();
 }
 /**
  * Run create frontend product rating test.
  *
  * @param Review $review
  * @param BrowserInterface $browser
  * @param AssertProductReviewIsAbsentOnProductPage $assertProductReviewIsAbsentOnProductPage
  * @return array
  */
 public function test(Review $review, BrowserInterface $browser, AssertProductReviewIsAbsentOnProductPage $assertProductReviewIsAbsentOnProductPage)
 {
     // Prepare for tear down
     $this->review = $review;
     // Steps
     $product = $review->getDataFieldConfig('entity_id')['source']->getEntity();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $assertProductReviewIsAbsentOnProductPage->processAssert($this->catalogProductView);
     $this->catalogProductView->getReviewSummary()->clickAddReviewLink();
     $reviewForm = $this->catalogProductView->getReviewFormBlock();
     $reviewForm->fill($review);
     $reviewForm->submit();
     return ['product' => $product];
 }
 /**
  * Run create frontend product rating test
  *
  * @param ReviewInjectable $review
  * @param Browser $browser
  * @return void
  */
 public function test(ReviewInjectable $review, Browser $browser)
 {
     // Prepare for tear down
     $this->review = $review;
     // Steps
     $product = $review->getDataFieldConfig('entity_id')['source']->getEntity();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewLink = $this->catalogProductView->getReviewSummary()->getAddReviewLink();
     if ($reviewLink->isVisible()) {
         $reviewLink->click();
     }
     $reviewForm = $this->catalogProductView->getReviewFormBlock();
     $reviewForm->fill($review);
     $reviewForm->submit();
 }
 /**
  * Test Creation for CustomerReviewReportEntity
  *
  * @param Review $review
  * @param Customer $customer
  * @param $customerLogin
  * @param CatalogProductSimple $product
  * @param BrowserInterface $browser
  * @return array
  *
  * @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass)
  */
 public function test(Review $review, Customer $customer, CatalogProductSimple $product, BrowserInterface $browser, $customerLogin)
 {
     // Preconditions
     $product->persist();
     $this->cmsIndex->open();
     if ($customerLogin == 'Yes') {
         $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     }
     // Steps
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->pageCatalogProductView->getReviewSummary()->getAddReviewLink()->click();
     $this->pageCatalogProductView->getReviewFormBlock()->fill($review);
     $this->pageCatalogProductView->getReviewFormBlock()->submit();
     return ['product' => $product];
 }
 /**
  * Test Creation for CustomerReviewReportEntity
  *
  * @param Review $review
  * @param Customer $customer
  * @param $customerLogin
  * @param CatalogProductSimple $product
  * @param BrowserInterface $browser
  * @return array
  *
  * @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass)
  */
 public function test(Review $review, Customer $customer, CatalogProductSimple $product, BrowserInterface $browser, $customerLogin)
 {
     // Preconditions
     $product->persist();
     $this->cmsIndex->open();
     if ($customerLogin == 'Yes') {
         $this->cmsIndex->getLinksBlock()->openLink("Log In");
         $this->customerAccountLogin->getLoginBlock()->login($customer);
     }
     // Steps
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->pageCatalogProductView->getReviewSummary()->getAddReviewLink()->click();
     $this->pageCatalogProductView->getReviewFormBlock()->fill($review);
     $this->pageCatalogProductView->getReviewFormBlock()->submit();
     return ['product' => $product];
 }
 /**
  * Assert that product review available on product page.
  *
  * @param CatalogProductView $catalogProductView
  * @param Review $review
  * @param FixtureInterface $product
  * @param BrowserInterface $browser
  * @param AdminCache $cachePage
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, Review $review, FixtureInterface $product, BrowserInterface $browser, AdminCache $cachePage)
 {
     $errors = [];
     $cachePage->open()->getActionsBlock()->flushMagentoCache();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewBlock = $catalogProductView->getCustomerReviewBlock();
     $catalogProductView->getViewBlock()->selectTab('Reviews');
     \PHPUnit_Framework_Assert::assertContains(sprintf("You're reviewing:\n%s", $product->getName()), $catalogProductView->getReviewFormBlock()->getLegend()->getText());
     foreach ($review->getData() as $name => $value) {
         $reviewValue = $reviewBlock->getFieldValue($name);
         if ($reviewValue !== null && 0 !== strcasecmp($value, trim($reviewValue))) {
             $errors[] = '- field "' . $name . '" is not equals submitted one, error value "' . $value . '"';
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, 'The Review contains the following errors:' . PHP_EOL . implode(PHP_EOL, $errors));
 }
 /**
  * Run manage product review test
  *
  * @param Review $reviewInitial
  * @param Review $review
  * @param Customer $customer
  * @return array
  */
 public function test(Review $reviewInitial, Review $review, Customer $customer)
 {
     // Preconditions
     $this->login($customer);
     /** @var CatalogProductSimple $product */
     $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->catalogProductView->getReviewSummary()->getAddReviewLink()->click();
     $this->catalogProductView->getReviewFormBlock()->fill($reviewInitial);
     $this->catalogProductView->getReviewFormBlock()->submit();
     $this->reviewInitial = $reviewInitial;
     // Steps
     $this->customerIndex->open();
     $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $this->customerIndexEdit->getCustomerForm()->openTab('product_reviews');
     $filter = ['title' => $reviewInitial->getTitle(), 'sku' => $product->getSku()];
     $this->customerIndexEdit->getCustomerForm()->getTabElement('product_reviews')->getReviewsGrid()->searchAndOpen($filter);
     $this->reviewEdit->getReviewForm()->fill($review);
     $this->reviewEdit->getPageActions()->save();
     return ['reviewInitial' => $reviewInitial, 'product' => $product];
 }