/**
  * Assert that review is displayed in grid.
  *
  * @param ReviewIndex $reviewIndex
  * @param Review $review
  * @param FixtureInterface $product
  * @param string $gridStatus
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, Review $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.');
 }
 /**
  * Asserts Product Review not available in grid
  *
  * @param ReviewIndex $reviewIndex
  * @param ReviewInjectable $review
  * @param string $gridStatus
  * @param ReviewInjectable $reviewInitial
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, ReviewInjectable $review, $gridStatus = '', ReviewInjectable $reviewInitial = null)
 {
     $product = $reviewInitial === null ? $review->getDataFieldConfig('entity_id')['source']->getEntity() : $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $filter = $this->prepareFilter($product, $review, $gridStatus);
     $reviewIndex->getReviewGrid()->search($filter);
     unset($filter['visible_in']);
     \PHPUnit_Framework_Assert::assertFalse($reviewIndex->getReviewGrid()->isRowVisible($filter, false), 'Review available in grid');
 }
 /**
  * Asserts Customer Product Review not available in grid
  *
  * @param ReviewIndex $reviewIndex
  * @param Review $review
  * @param AssertProductReviewNotInGrid $assertProductReviewNotInGrid
  * @param CustomerReportReview $customerReportReview
  * @param Customer $customer
  * @param CatalogProductSimple $product
  * @param string $gridStatus
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, Review $review, AssertProductReviewNotInGrid $assertProductReviewNotInGrid, CustomerReportReview $customerReportReview, Customer $customer, CatalogProductSimple $product, $gridStatus = '')
 {
     $filter = $assertProductReviewNotInGrid->prepareFilter($product, $review, $gridStatus);
     $customerReportReview->open();
     $customerReportReview->getGridBlock()->openReview($customer);
     $reviewIndex->getReviewGrid()->search($filter);
     unset($filter['visible_in']);
     \PHPUnit_Framework_Assert::assertFalse($reviewIndex->getReviewGrid()->isRowVisible($filter, false), 'Customer review is present in Review grid.');
 }
 /**
  * Assert that review is visible in review grid for select product
  *
  * @param ReviewIndex $reviewIndex
  * @param Review $review
  * @param ProductReportReview $productReportReview
  * @param AssertProductReviewInGrid $assertProductReviewInGrid
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex, Review $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->getData(), '');
     \PHPUnit_Framework_Assert::assertTrue($reviewIndex->getReviewGrid()->isRowVisible($filter, false), 'Review for ' . $product->getName() . ' product is not visible in reports grid.');
 }
 /**
  * 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 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);
 }
 /**
  * Run moderate product review test.
  *
  * @param Review $reviewInitial
  * @param Review $review
  * @return array
  */
 public function test(Review $reviewInitial, Review $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];
 }
 /**
  * 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);
 }
 /**
  * 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();
 }
 /**
  * Run Create Product Review Entity Backend Test
  *
  * @param ReviewInjectable $review
  * @return void
  */
 public function test(ReviewInjectable $review)
 {
     // Precondition:
     $filter = ['id' => $review->getDataFieldConfig('entity_id')['source']->getEntity()->getId()];
     $this->review = $review;
     // Steps:
     $this->reviewIndex->open();
     $this->reviewIndex->getReviewActions()->addNew();
     $this->reviewEdit->getProductGrid()->searchAndOpen($filter);
     $this->reviewEdit->getReviewForm()->fill($this->review);
     $this->reviewEdit->getPageActions()->save();
 }
 /**
  * Assert that success message is displayed after deletion via mass actions
  *
  * @param Review|Review[] $review
  * @param ReviewIndex $reviewIndex
  * @return void
  */
 public function processAssert(Review $review, ReviewIndex $reviewIndex)
 {
     $reviews = is_array($review) ? $review : [$review];
     $deleteMessage = sprintf(self::SUCCESS_DELETE_MESSAGE, count($reviews));
     \PHPUnit_Framework_Assert::assertEquals($deleteMessage, $reviewIndex->getMessagesBlock()->getSuccessMessage(), 'Wrong success message is displayed.');
 }
 /**
  * Assert that success message is displayed after review created
  *
  * @param ReviewIndex $reviewIndex
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $reviewIndex->getMessagesBlock()->getSuccessMessages(), 'Wrong success message is displayed.');
 }
 /**
  * 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);
 }
 /**
  * Assert that success message is displayed after review save
  *
  * @param ReviewIndex $reviewIndex
  * @return void
  */
 public function processAssert(ReviewIndex $reviewIndex)
 {
     $actualMessage = $reviewIndex->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_MESSAGE . "\nActual: " . $actualMessage);
 }
 /**
  * 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.');
 }