Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductInStock.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Product\CatalogProductView;
10 use Magento\Mtf\Client\BrowserInterface;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 use Magento\Mtf\Fixture\FixtureInterface;
13 
17 class AssertProductInStock extends AbstractConstraint
18 {
22  const STOCK_AVAILABILITY = 'in stock';
23 
32  public function processAssert(
33  CatalogProductView $catalogProductView,
34  BrowserInterface $browser,
35  FixtureInterface $product
36  ) {
37  // TODO fix initialization url for frontend page
38  $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
39  \PHPUnit\Framework\Assert::assertEquals(
40  self::STOCK_AVAILABILITY,
41  $catalogProductView->getViewBlock()->stockAvailability(),
42  'Control "' . self::STOCK_AVAILABILITY . '" is not visible.'
43  );
44  }
45 
51  public function toString()
52  {
53  return 'In stock control is visible.';
54  }
55 }
processAssert(CatalogProductView $catalogProductView, BrowserInterface $browser, FixtureInterface $product)