/**
  * Prepare fixture data.
  *
  * @param Review $review
  * @param string $status
  * @return array
  */
 protected function prepareFixtureData(Review $review, $status)
 {
     $reviewData = $review->getData();
     if ($status !== '') {
         $reviewData['status_id'] = $status;
     }
     return $reviewData;
 }
 /**
  * Assert that product review can do approved.
  *
  * @param CatalogProductReview $reviewIndex
  * @param Review $review
  * @param CatalogProductReviewEdit $reviewEdit
  * @param AssertReviewSuccessSaveMessage $assertReviewSuccessSaveMessage
  * @param Cache $cachePage
  * @return void
  */
 public function processAssert(CatalogProductReview $reviewIndex, Review $review, CatalogProductReviewEdit $reviewEdit, AssertReviewSuccessSaveMessage $assertReviewSuccessSaveMessage, Cache $cachePage)
 {
     $reviewIndex->open()->getReviewGrid()->searchAndOpen(['title' => $review->getTitle()]);
     $reviewEdit->getReviewForm()->setApproveReview();
     $reviewEdit->getFormPageActions()->save();
     $assertReviewSuccessSaveMessage->processAssert($reviewIndex);
     $cachePage->open()->getPageActions()->flushCacheStorage();
 }
 /**
  * Assert that product rating is displayed on product review(backend) page.
  *
  * @param CatalogProductReview $reviewIndex
  * @param CatalogProductReviewEdit $reviewEdit
  * @param Review $review
  * @return void
  */
 public function processAssert(CatalogProductReview $reviewIndex, CatalogProductReviewEdit $reviewEdit, Review $review)
 {
     $reviewIndex->open();
     $reviewIndex->getReviewGrid()->searchAndOpen(['title' => $review->getTitle()]);
     $ratingReview = $this->sortDataByPath($review->getRatings(), '::title');
     $ratingForm = $this->sortDataByPath($reviewEdit->getReviewForm()->getData()['ratings'], '::title');
     $error = $this->verifyData($ratingReview, $ratingForm);
     \PHPUnit_Framework_Assert::assertEmpty($error, $error);
 }
 /**
  * Assert that product rating is displayed on product review page(frontend).
  *
  * @param CatalogProductView $catalogProductView
  * @param ReviewProductList $reviewProductList
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param Review $review
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, ReviewProductList $reviewProductList, BrowserInterface $browser, CatalogProductSimple $product, Review $review)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->openCustomInformationTab('Reviews');
     $catalogProductView->getReviewsBlock()->clickAddReviewLink();
     $reviewForm = $reviewProductList->getReviewFormBlock();
     $ratings = $review->getDataFieldConfig('ratings')['source']->getRatings();
     foreach ($ratings as $rating) {
         \PHPUnit_Framework_Assert::assertTrue($reviewForm->isVisibleRating($rating), 'Product rating "' . $rating->getRatingCode() . '" is not displayed on review product page.');
     }
 }
Exemplo n.º 5
0
 /**
  * Fill ratings on the review form.
  *
  * @param ReviewFixture $review
  * @return void
  */
 protected function fillRatings(ReviewFixture $review)
 {
     $ratingsData = $review->getRatings();
     $ratingsFixture = $review->getDataFieldConfig('ratings')['source']->getRatings();
     foreach ($ratingsData as $key => $value) {
         $this->setRating($ratingsFixture[$key], $value['rating']);
     }
 }
 /**
  * Add review to product via frontend.
  *
  * @return array
  */
 public function run()
 {
     $product = $this->review->getDataFieldConfig('entity_id')['source']->getEntity();
     $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     if ($this->isFirstReview) {
         $this->assertProductReviewIsAbsentOnProductPage->processAssert();
     }
     $this->catalogProductView->getViewBlock()->openCustomInformationTab('Reviews');
     $this->catalogProductView->getReviewsBlock()->clickAddReviewLink();
     $reviewForm = $this->reviewProductList->getReviewFormBlock();
     $reviewForm->fill($this->review);
     $reviewForm->submit();
     return ['product' => $product, 'review' => $this->review];
 }
 /**
  * Assert that review is displayed in grid.
  *
  * @param CatalogProductReview $reviewIndex
  * @param Review $review
  * @param InjectableFixture $product
  * @param string $gridStatus [optional]
  * @return void
  */
 public function processAssert(CatalogProductReview $reviewIndex, Review $review, InjectableFixture $product, $gridStatus = '')
 {
     $reviewIndex->open();
     $filter = $this->prepareFilter($product, $review->getData(), $gridStatus);
     \PHPUnit_Framework_Assert::assertTrue($reviewIndex->getReviewGrid()->isRowVisible($filter), 'Review is absent in Review grid.');
 }
 /**
  * Prepare fixture review data.
  *
  * @param Review $review
  * @return array
  */
 protected function prepareReview(Review $review)
 {
     return ['title' => $review->getTitle(), 'detail' => $review->getDetail(), 'nickname' => $review->getNickname(), 'ratings' => $review->getRatings()];
 }