/**
  * 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 review is displayed in grid
  *
  * @param ReviewIndex $reviewIndex
  * @param ReviewInjectable $review ,
  * @param FixtureInterface $product
  * @param string $gridStatus
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, ReviewInjectable $review, FixtureInterface $product, $gridStatus = '')
 {
     $filter = $this->prepareFilter($product, $review->getData(), $gridStatus);
     $reviewIndex->open();
     $reviewIndex->getReviewGrid()->search($filter);
     unset($filter['visible_in']);
     \PHPUnit_Framework_Assert::assertTrue($reviewIndex->getReviewGrid()->isRowVisible($filter, false), 'Review is absent in Review grid.');
 }
 /**
  * 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 review Not available on product page
  *
  * @param CatalogProductView $catalogProductView
  * @param ReviewInjectable $reviewInitial
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, ReviewInjectable $reviewInitial, Browser $browser)
 {
     /** @var CatalogProductSimple $product */
     $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewBlock = $catalogProductView->getCustomerReviewBlock();
     $catalogProductView->getViewBlock()->selectTab('Reviews');
     \PHPUnit_Framework_Assert::assertFalse($reviewBlock->isVisibleReviewItem(), 'Error, product review is displayed.');
 }
 /**
  * Assert that review is visible in review grid for select product
  *
  * @param ReviewIndex $reviewIndex
  * @param ReviewInjectable $review
  * @param ProductReportReview $productReportReview
  * @param AssertProductReviewInGrid $assertProductReviewInGrid
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, ReviewInjectable $review, ProductReportReview $productReportReview, AssertProductReviewInGrid $assertProductReviewInGrid)
 {
     $productReportReview->open();
     $product = $review->getDataFieldConfig('entity_id')['source']->getEntity();
     $productReportReview->getGridBlock()->openReview($product->getName());
     unset($assertProductReviewInGrid->filter['visible_in']);
     $filter = $assertProductReviewInGrid->prepareFilter($product, $review, '');
     \PHPUnit_Framework_Assert::assertTrue($reviewIndex->getReviewGrid()->isRowVisible($filter, false), 'Review for ' . $product->getName() . ' product is not visible in reports grid.');
 }
 /**
  * Assert that product rating is displayed on product review(frontend)
  *
  * @param CatalogProductView $catalogProductView
  * @param Browser $browser
  * @param CatalogProductSimple $product
  * @param ReviewInjectable|null $review [optional]
  * @param Rating|null $productRating [optional]
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, Browser $browser, CatalogProductSimple $product, ReviewInjectable $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.');
 }
 /**
  * Assert that product rating is displayed on product review(backend)
  *
  * @param ReviewIndex $reviewIndex
  * @param ReviewEdit $reviewEdit
  * @param ReviewInjectable $review
  * @param ReviewInjectable|null $reviewInitial [optional]
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, ReviewEdit $reviewEdit, ReviewInjectable $review, ReviewInjectable $reviewInitial = null)
 {
     $filter = ['title' => $review->getTitle()];
     $reviewIndex->open();
     $reviewIndex->getReviewGrid()->searchAndOpen($filter);
     $ratingReview = array_replace($reviewInitial && $reviewInitial->hasData('ratings') ? $reviewInitial->getRatings() : [], $review->hasData('ratings') ? $review->getRatings() : []);
     $ratingReview = $this->sortDataByPath($ratingReview, '::title');
     $ratingForm = $reviewEdit->getReviewForm()->getData();
     $ratingForm = $this->sortDataByPath($ratingForm['ratings'], '::title');
     $error = $this->verifyData($ratingReview, $ratingForm);
     \PHPUnit_Framework_Assert::assertTrue(empty($error), $error);
 }
 /**
  * Prepare Review data
  *
  * @param ReviewInjectable $review
  * @param ReviewInjectable $reviewInitial
  * @return array
  */
 protected function prepareData(ReviewInjectable $review, ReviewInjectable $reviewInitial)
 {
     $dataReviewInitial = $reviewInitial->getData();
     $data = $review->getData();
     foreach ($dataReviewInitial as $key => $value) {
         if (!isset($data[$key])) {
             $data[$key] = $value;
         }
     }
     $data['type'] = 'Customer';
     return $data;
 }
 /**
  * Assert that product review available on product page
  *
  * @param CatalogProductView $catalogProductView
  * @param ReviewInjectable $review
  * @param FixtureInterface $product
  * @param Browser $browser
  * @param AdminCache $cachePage
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, ReviewInjectable $review, FixtureInterface $product, Browser $browser, AdminCache $cachePage)
 {
     $errors = [];
     $cachePage->open()->getActionsBlock()->flushMagentoCache();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewBlock = $catalogProductView->getCustomerReviewBlock();
     $catalogProductView->getViewBlock()->selectTab('Reviews');
     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));
 }
 /**
  * Prepare filter for assert
  *
  * @param FixtureInterface $product
  * @param ReviewInjectable $review
  * @param string $gridStatus
  * @return array
  */
 public function prepareFilter(FixtureInterface $product, ReviewInjectable $review, $gridStatus)
 {
     $filter = [];
     foreach ($this->filter as $key => $item) {
         list($type, $param) = [$key, $item];
         if (is_numeric($key)) {
             $type = $param = $item;
         }
         switch ($param) {
             case 'name':
             case 'sku':
                 $value = $product->getData($param);
                 break;
             case 'select_stores':
                 $value = $review->getData($param)[0];
                 break;
             case 'status_id':
                 $value = $gridStatus != '' ? $gridStatus : $review->getData($param);
                 break;
             default:
                 $value = $review->getData($param);
                 break;
         }
         if ($value !== null) {
             $filter += [$type => $value];
         }
     }
     return $filter;
 }
 /**
  * Assert that product review available on product page
  *
  * @param CatalogProductView $catalogProductView
  * @param ReviewInjectable $review
  * @param ReviewInjectable $reviewInitial
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, ReviewInjectable $review, ReviewInjectable $reviewInitial, Browser $browser)
 {
     $errors = [];
     /** @var CatalogProductSimple $product */
     $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewBlock = $catalogProductView->getCustomerReviewBlock();
     $catalogProductView->getViewBlock()->selectTab('Reviews');
     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 moderate product review test
  *
  * @param ReviewInjectable $reviewInitial
  * @param ReviewInjectable $review
  * @return void
  */
 public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review)
 {
     // Precondition
     $reviewInitial->persist();
     // Steps
     $this->reviewIndex->open();
     $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]);
     $this->reviewEdit->getReviewForm()->fill($review);
     $this->reviewEdit->getPageActions()->save();
 }
 /**
  * Clear data after test
  *
  * @return void
  */
 public function tearDown()
 {
     $this->ratingIndex->open();
     if ($this->review instanceof ReviewInjectable) {
         foreach ($this->review->getRatings() as $rating) {
             $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]);
             $this->ratingEdit->getPageActions()->delete();
         }
     }
 }
 /**
  * Clear data after test
  *
  * @return void
  */
 public function tearDown()
 {
     $this->ratingIndex->open();
     $ratingGrid = $this->ratingIndex->getRatingGrid();
     $pageActions = $this->ratingEdit->getPageActions();
     foreach ($this->review->getRatings() as $rating) {
         $ratingGrid->searchAndOpen(['rating_code' => $rating['title']]);
         $pageActions->delete();
     }
 }
 /**
  * Run moderate product review test
  *
  * @param ReviewInjectable $reviewInitial
  * @param ReviewInjectable $review
  * @return array
  */
 public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review)
 {
     // Precondition
     $reviewInitial->persist();
     // Steps
     $this->reviewIndex->open();
     $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]);
     $this->reviewEdit->getReviewForm()->fill($review);
     $this->reviewEdit->getPageActions()->save();
     // Prepare data for asserts
     $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     return ['product' => $product];
 }
 /**
  * Creation product review report entity
  *
  * @param ReviewInjectable $review
  * @return void
  */
 public function test(ReviewInjectable $review)
 {
     // Preconditions
     $review->persist();
 }
 /**
  * Assert that Product Review Report is visible in reports grid
  *
  * @param ProductReportReview $productReportReview
  * @param ReviewInjectable $review
  * @return void
  */
 public function processAssert(ProductReportReview $productReportReview, ReviewInjectable $review)
 {
     $productReportReview->open();
     $name = $review->getDataFieldConfig('entity_id')['source']->getEntity()->getName();
     \PHPUnit_Framework_Assert::assertTrue($productReportReview->getGridBlock()->isRowVisible(['title' => $name], false), 'Review for ' . $name . ' product is not visible in reports grid.');
 }
 /**
  * Assert that review is displayed in grid
  *
  * @param ReviewIndex $reviewIndex
  * @param ReviewInjectable $review
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, ReviewInjectable $review)
 {
     $filter = ['title' => $review->getTitle()];
     $reviewIndex->open();
     \PHPUnit_Framework_Assert::assertTrue($reviewIndex->getReviewGrid()->isRowVisible($filter), 'Review with ' . 'title "' . $filter['title'] . '"' . 'is absent in Review grid.');
 }
Example #19
0
 /**
  * Fill ratings on the review form
  *
  * @param ReviewInjectable $review
  * @return void
  */
 protected function fillRatings(ReviewInjectable $review)
 {
     if (!$review->hasData('ratings')) {
         return;
     }
     foreach ($review->getRatings() as $rating) {
         $this->setRating($rating['title'], $rating['rating']);
     }
 }