Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateVirtualProductEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Fixture\CatalogProductVirtual;
11 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
12 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
13 use Magento\Mtf\Fixture\FixtureFactory;
14 use Magento\Mtf\TestCase\Injectable;
15 
36 class UpdateVirtualProductEntityTest extends Injectable
37 {
38  /* tags */
39  const MVP = 'no';
40  /* end tags */
41 
47  protected $product;
48 
54  protected $productGrid;
55 
61  protected $editProductPage;
62 
69  public function __prepare(Category $category)
70  {
71  $category->persist();
72  return [
73  'category' => $category
74  ];
75  }
76 
86  public function __inject(
87  CatalogProductIndex $productGrid,
88  CatalogProductEdit $editProductPage,
89  Category $category,
90  FixtureFactory $fixtureFactory
91  ) {
92  $this->product = $fixtureFactory->createByCode(
93  'catalogProductVirtual',
94  [
95  'dataset' => 'default',
96  'data' => [
97  'category_ids' => [
98  'category' => $category,
99  ],
100  ]
101  ]
102  );
103  $this->product->persist();
104 
105  $this->productGrid = $productGrid;
106  $this->editProductPage = $editProductPage;
107  }
108 
115  public function test(CatalogProductVirtual $product)
116  {
117  // Steps
118  $this->productGrid->open();
119  $this->productGrid->getProductGrid()->searchAndOpen(['sku' => $this->product->getSku()]);
120  $this->editProductPage->getProductForm()->fill($product);
121  $this->editProductPage->getFormPageActions()->save();
122  }
123 }
__inject(CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, Category $category, FixtureFactory $fixtureFactory)