Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertReviewLinksIsPresentOnProductPage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Client\Browser;
10 use Magento\Mtf\Fixture\InjectableFixture;
11 use Magento\Catalog\Test\Page\Product\CatalogProductView;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 
17 class AssertReviewLinksIsPresentOnProductPage extends AbstractConstraint
18 {
24  protected $severeness = 'middle';
25 
34  public function processAssert(Browser $browser, CatalogProductView $catalogProductView, InjectableFixture $product)
35  {
36  $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
37 
38  // Verify add review link
39  \PHPUnit\Framework\Assert::assertTrue(
40  $catalogProductView->getReviewSummary()->getAddReviewLink()->isVisible(),
41  'Add review link is not visible on product page.'
42  );
43 
44  // Verify view review link
45  $viewReviewLink = $catalogProductView->getReviewSummary()->getViewReviewLink();
46  \PHPUnit\Framework\Assert::assertTrue(
47  $viewReviewLink->isVisible(),
48  'View review link is not visible on product page.'
49  );
50  \PHPUnit\Framework\Assert::assertContains(
51  '1',
52  $viewReviewLink->getText(),
53  'There is more than 1 approved review.'
54  );
55  }
56 
62  public function toString()
63  {
64  return 'Add and view review links are present on product page.';
65  }
66 }