Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteProductEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Mtf\TestCase\Injectable;
13 
29 class DeleteProductEntityTest extends Injectable
30 {
31  /* tags */
32  const MVP = 'yes';
33  /* end tags */
34 
41 
48  public function __prepare(Category $category)
49  {
50  $category->persist();
51  return [
52  'category' => $category
53  ];
54  }
55 
62  public function __inject(CatalogProductIndex $catalogProductIndexPage)
63  {
64  $this->catalogProductIndex = $catalogProductIndexPage;
65  }
66 
75  public function test($products, FixtureFactory $fixtureFactory, Category $category)
76  {
77  //Steps
78  $products = explode(',', $products);
79  $deleteProducts = [];
80  foreach ($products as &$product) {
81  list($fixture, $dataset) = explode('::', $product);
82  $product = $fixtureFactory->createByCode(
83  $fixture,
84  [
85  'dataset' => $dataset,
86  'data' => [
87  'category_ids' => [
88  'category' => $category,
89  ],
90  ]
91  ]
92  );
93  $product->persist();
94  $deleteProducts[] = ['sku' => $product->getSku()];
95  }
96  $this->catalogProductIndex->open();
97  $this->catalogProductIndex->getProductGrid()->massaction($deleteProducts, 'Delete', true);
98 
99  return ['product' => $products];
100  }
101 }
test($products, FixtureFactory $fixtureFactory, Category $category)