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 use Magento\Mtf\Fixture\FixtureFactory;
36 BrowserInterface $browser,
38 FixtureFactory $fixtureFactory,
39 CatalogProductView $catalogProductView,
42 foreach ($threshold as $thresholdItem) {
43 $this->buyProduct($fixtureFactory,
$product, $thresholdItem[
'qty']);
44 $browser->open($_ENV[
'app_frontend_url'] .
$product->getUrlKey() .
'.html');
45 $isThresholdMessageDisplayed = $catalogProductView->getViewBlock()
46 ->isThresholdMessageDisplayed($browser,
$product);
47 \PHPUnit\Framework\Assert::assertEquals(
48 $isThresholdMessageDisplayed,
49 $thresholdItem[
'is_message_displayed'],
50 'Product inventory threshold message display is not correct.' 52 if ($thresholdItem[
'is_message_displayed']) {
53 \PHPUnit\Framework\Assert::assertEquals(
54 sprintf(self::SUCCESS_MESSAGE, $thresholdItem[
'expected']),
55 $catalogProductView->getViewBlock()->getThresholdMessage(),
56 'Product inventory success message is not displayed.' 70 private function buyProduct(FixtureFactory $fixtureFactory, FixtureInterface
$product, $qty)
72 $newProduct = $fixtureFactory->createByCode(
73 'catalogProductSimple',
74 [
'data' => [
'sku' =>
$product->getSku(),
'checkout_data' => [
'qty' => $qty]]]
76 $order = $fixtureFactory->createByCode(
'orderInjectable', [
80 'products' => [$newProduct]
94 return 'Product inventory threshold message display is correct.';
processAssert(BrowserInterface $browser, FixtureInterface $product, FixtureFactory $fixtureFactory, CatalogProductView $catalogProductView, array $threshold)