/** * Assert that add view review links are present on product page. * * @param Browser $browser * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @return void */ public function processAssert(Browser $browser, CatalogProductView $catalogProductView, InjectableFixture $product) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); // Verify add review link \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getReviewSummary()->getAddReviewLink()->isVisible(), 'Add review link is not visible on product page.'); // Verify view review link $viewReviewLink = $catalogProductView->getReviewSummary()->getViewReviewLink(); \PHPUnit_Framework_Assert::assertTrue($viewReviewLink->isVisible(), 'View review link is not visible on product page.'); \PHPUnit_Framework_Assert::assertContains('1', $viewReviewLink->getText(), 'There is more than 1 approved review.'); }
/** * 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 * @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 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 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]; }
/** * 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]; }
/** * Assert that product doesn't have a review on product page. * * @param CatalogProductView $catalogProductView * @return void */ public function processAssert(CatalogProductView $catalogProductView) { $catalogProductView->getViewBlock()->selectTab('Reviews'); \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getCustomerReviewBlock()->isVisibleReviewItem(), 'No reviews below the form required.'); \PHPUnit_Framework_Assert::assertEquals(self::NO_REVIEW_LINK_TEXT, trim($catalogProductView->getReviewSummary()->getAddReviewLink()->getText()), sprintf('"%s" link is not available', self::NO_REVIEW_LINK_TEXT)); }