Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ManageProductsStockTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\Fixture\FixtureFactory;
11 use Magento\Mtf\TestCase\Injectable;
12 
26 class ManageProductsStockTest extends Injectable
27 {
28  /* tags */
29  const MVP = 'yes';
30  /* end tags */
31 
37  protected $fixtureFactory;
38 
44  protected $configData;
45 
52  public function __inject(FixtureFactory $fixtureFactory)
53  {
54  $this->fixtureFactory = $fixtureFactory;
55  }
56 
65  public function test(CatalogProductSimple $product, $skipAddingToCart = null, $configData = null)
66  {
67  $this->configData = $configData;
68  $this->objectManager->create(
69  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
70  ['configData' => $this->configData]
71  )->run();
72 
73  // Preconditions
74  $product->persist();
75 
76  // Steps
77  if (!$skipAddingToCart) {
78  $this->objectManager->create(
79  \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class,
80  ['products' => [$product]]
81  )->run();
82 
83  $cart['data']['items'] = ['products' => [$product]];
84 
85  return ['cart' => $this->fixtureFactory->createByCode('cart', $cart)];
86  }
87  }
88 
94  public function tearDown()
95  {
96  $this->objectManager->create(
97  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
98  ['configData' => $this->configData, 'rollback' => true]
99  )->run();
100  }
101 }
test(CatalogProductSimple $product, $skipAddingToCart=null, $configData=null)