Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductOutOfStock.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 AssertProductOutOfStock extends AbstractConstraint
18 {
22  const STOCK_AVAILABILITY = 'out of stock';
23 
32  public function processAssert(
33  CatalogProductView $catalogProductView,
34  BrowserInterface $browser,
35  FixtureInterface $product
36  ) {
37  $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
38  \PHPUnit\Framework\Assert::assertEquals(
39  self::STOCK_AVAILABILITY,
40  $catalogProductView->getViewBlock()->stockAvailability(),
41  'Control \'' . self::STOCK_AVAILABILITY . '\' is not visible.'
42  );
43  }
44 
50  public function toString()
51  {
52  return 'Out of stock control is visible.';
53  }
54 }
processAssert(CatalogProductView $catalogProductView, BrowserInterface $browser, FixtureInterface $product)