Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductReviewOnProductPage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\PageCache\Test\Page\Adminhtml\AdminCache;
10 use Magento\Catalog\Test\Page\Product\CatalogProductView;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
14 use Magento\Mtf\Fixture\FixtureInterface;
15 
19 class AssertProductReviewOnProductPage extends AbstractConstraint
20 {
31  public function processAssert(
32  CatalogProductView $catalogProductView,
33  Review $review,
34  FixtureInterface $product,
35  BrowserInterface $browser,
36  AdminCache $cachePage
37  ) {
38  $errors = [];
39  $cachePage->open()->getActionsBlock()->flushMagentoCache();
40  $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
41 
42  $reviewBlock = $catalogProductView->getCustomerReviewBlock();
43  $catalogProductView->getViewBlock()->selectTab('Reviews');
44 
45  \PHPUnit\Framework\Assert::assertContains(
46  sprintf("You're reviewing:\n%s", $product->getName()),
47  $catalogProductView->getReviewFormBlock()->getLegend()->getText()
48  );
49 
50  foreach ($review->getData() as $name => $value) {
51  $reviewValue = $reviewBlock->getFieldValue($name);
52  if (($reviewValue !== null) && (0 !== strcasecmp($value, trim($reviewValue)))) {
53  $errors[] = '- field "' . $name . '" is not equals submitted one, error value "' . $value . '"';
54  }
55  }
56 
57  \PHPUnit\Framework\Assert::assertEmpty(
58  $errors,
59  'The Review contains the following errors:' . PHP_EOL . implode(PHP_EOL, $errors)
60  );
61  }
62 
68  public function toString()
69  {
70  return 'Product review is displayed correct.';
71  }
72 }
$value
Definition: gender.phtml:16
processAssert(CatalogProductView $catalogProductView, Review $review, FixtureInterface $product, BrowserInterface $browser, AdminCache $cachePage)
$errors
Definition: overview.phtml:9
if(!isset($_GET['name'])) $name
Definition: log.php:14