Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DuplicateProductEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
11 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
12 use Magento\Mtf\Fixture\FixtureFactory;
13 use Magento\Mtf\TestCase\Injectable;
14 
29 class DuplicateProductEntityTest extends Injectable
30 {
31  /* tags */
32  const MVP = 'yes';
33  /* end tags */
34 
40  protected $category;
41 
47  protected $productGrid;
48 
54  protected $editProductPage;
55 
61  protected $fixtureFactory;
62 
72  public function __prepare(
73  Category $category,
74  CatalogProductIndex $productGrid,
75  CatalogProductEdit $editProductPage,
76  FixtureFactory $fixtureFactory
77  ) {
78  $this->category = $category;
79  $this->category->persist();
80  $this->productGrid = $productGrid;
81  $this->editProductPage = $editProductPage;
82  $this->fixtureFactory = $fixtureFactory;
83  }
84 
91  public function test($productType)
92  {
93  $this->markTestIncomplete('https://github.com/magento-engcom/msi/issues/666');
94 
95  // Precondition
96  $product = $this->createProduct($productType);
97 
98  // Steps
99  $filter = ['sku' => $product->getSku()];
100  $this->productGrid->open();
101  $this->productGrid->getProductGrid()->searchAndOpen($filter);
102  $this->editProductPage->getFormPageActions()->saveAndDuplicate();
103 
104  return ['product' => $product];
105  }
106 
113  protected function createProduct($productType)
114  {
115  list($fixture, $dataset) = explode('::', $productType);
116  $product = $this->fixtureFactory->createByCode(
117  $fixture,
118  [
119  'dataset' => $dataset,
120  'data' => [
121  'category_ids' => [
122  'category' => $this->category,
123  ],
124  ]
125  ]
126  );
127  $product->persist();
128 
129  return $product;
130  }
131 }
__prepare(Category $category, CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, FixtureFactory $fixtureFactory)