|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +use Magento\Framework\Exception\NoSuchEntityException; |
6 | 7 |
|
7 |
| -use Magento\Catalog\Model\Product; |
8 |
| -use Magento\Catalog\Model\ResourceModel\Product\Collection; |
9 |
| -use Magento\Framework\Registry; |
10 |
| -use Magento\TestFramework\Helper\Bootstrap; |
| 8 | +\Magento\TestFramework\Helper\Bootstrap::getInstance()->getInstance()->reinitialize(); |
11 | 9 |
|
12 |
| -/** @var Registry $registry */ |
13 |
| -$registry = Bootstrap::getObjectManager()->get(Registry::class); |
| 10 | +/** @var \Magento\Framework\Registry $registry */ |
| 11 | +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); |
14 | 12 |
|
15 | 13 | $registry->unregister('isSecureArea');
|
16 | 14 | $registry->register('isSecureArea', true);
|
17 | 15 |
|
18 |
| -/** @var Collection $productCollection */ |
19 |
| -$productCollection = Bootstrap::getObjectManager()->get(Product::class)->getCollection(); |
20 |
| -$productCollection->delete(); |
21 |
| - |
| 16 | +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ |
| 17 | +$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() |
| 18 | + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); |
| 19 | +try { |
| 20 | + $product = $productRepository->get('simple', false, null, true); |
| 21 | + $productRepository->delete($product); |
| 22 | +} catch (NoSuchEntityException $e) { |
| 23 | +} |
22 | 24 | $registry->unregister('isSecureArea');
|
23 | 25 | $registry->register('isSecureArea', false);
|
0 commit comments