/**
  * Assert that product review can do approved.
  *
  * @param ReviewIndex $reviewIndex
  * @param Review $review
  * @param ReviewEdit $reviewEdit
  * @param AssertReviewSuccessSaveMessage $assertReviewSuccessSaveMessage
  * @param AdminCache $cachePage
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, Review $review, ReviewEdit $reviewEdit, AssertReviewSuccessSaveMessage $assertReviewSuccessSaveMessage, AdminCache $cachePage)
 {
     $this->cachePage = $cachePage;
     $reviewIndex->open();
     $reviewGrid = $reviewIndex->getReviewGrid();
     $reviewGrid->searchAndOpen(['title' => $review->getTitle()]);
     $reviewEdit->getReviewForm()->setApproveReview();
     $reviewEdit->getPageActions()->save();
     $assertReviewSuccessSaveMessage->processAssert($reviewIndex);
     $this->flushCacheStorageWithAssert();
 }
 /**
  * Assert that product rating is displayed on product review(backend)
  *
  * @param ReviewIndex $reviewIndex
  * @param ReviewEdit $reviewEdit
  * @param Review $review
  * @param Review|null $reviewInitial [optional]
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, ReviewEdit $reviewEdit, Review $review, Review $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);
 }
 /**
  * Assert that review data on edit page equals passed from fixture.
  *
  * @param ReviewIndex $reviewIndex
  * @param Review $review
  * @param ReviewEdit $reviewEdit
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, Review $review, ReviewEdit $reviewEdit)
 {
     $reviewIndex->open();
     $reviewGrid = $reviewIndex->getReviewGrid();
     $reviewGrid->searchAndOpen(['title' => $review->getTitle()]);
     $fixtureData = $review->getData();
     $formData = $reviewEdit->getReviewForm()->getData();
     if (isset($fixtureData['type'])) {
         $formData['type'] = $reviewEdit->getReviewForm()->getPostedBy();
     }
     $error = $this->verifyData($fixtureData, $formData);
     \PHPUnit_Framework_Assert::assertEmpty($error, $error);
 }
 /**
  * Update product review on product page.
  *
  * @param Review $review
  * @param int $rating
  * @return array
  */
 public function test(Review $review, $rating)
 {
     // Steps
     $review = $this->createReview($review, $rating);
     $product = $this->reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $this->objectManager->create('Magento\\Catalog\\Test\\TestStep\\OpenProductOnBackendStep', ['product' => $product])->run();
     $this->catalogProductEdit->getProductForm()->openTab('product_reviews');
     $filter = ['title' => $this->reviewInitial->getTitle(), 'sku' => $product->getSku()];
     $this->catalogProductEdit->getProductForm()->getTab('product_reviews')->getReviewsGrid()->searchAndOpen($filter);
     $this->reviewEdit->getReviewForm()->fill($review);
     $this->reviewEdit->getPageActions()->save();
     $productRating = $this->reviewInitial->getDataFieldConfig('ratings')['source']->getRatings()[0];
     return ['product' => $product, 'productRating' => $productRating];
 }
 /**
  * Update product review on product page
  *
  * @param Review $review
  * @param int $rating
  * @return array
  */
 public function test(Review $review, $rating)
 {
     // Steps
     $review = $this->createReview($review, $rating);
     $this->catalogProductIndex->open();
     /** @var CatalogProductSimple $product */
     $product = $this->reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     $this->catalogProductEdit->getProductForm()->openTab('product_reviews');
     $filter = ['title' => $this->reviewInitial->getTitle(), 'sku' => $product->getSku()];
     $this->catalogProductEdit->getProductForm()->getTabElement('product_reviews')->getReviewsGrid()->searchAndOpen($filter);
     $this->reviewEdit->getReviewForm()->fill($review);
     $this->reviewEdit->getPageActions()->save();
     $productRating = $this->reviewInitial->getDataFieldConfig('ratings')['source']->getRatings()[0];
     return ['product' => $product, 'productRating' => $productRating];
 }
 /**
  * Apply for MassActions ProductReviewEntity.
  *
  * @param string $gridActions
  * @param string $gridStatus
  * @return void
  */
 public function test($gridActions, $gridStatus)
 {
     // Steps
     $this->reviewIndex->open();
     $this->reviewIndex->getReviewGrid()->massaction([['title' => $this->review->getTitle()]], [$gridActions => $gridStatus], $gridActions == 'Delete' ? true : false);
 }