|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -use Magento\Catalog\Api\ProductRepositoryInterface; |
8 |
| -use Magento\Customer\Model\CustomerRegistry; |
9 |
| -use Magento\Framework\DataObject; |
10 |
| -use Magento\TestFramework\Helper\Bootstrap; |
| 7 | +use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; |
11 | 8 | use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
12 |
| -use Magento\Wishlist\Model\Wishlist; |
13 | 9 |
|
14 |
| -Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php'); |
15 |
| -Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_disabled.php'); |
| 10 | +Resolver::getInstance()->requireDataFixture('Magento/Wishlist/_files/wishlist.php'); |
| 11 | + |
| 12 | +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 13 | +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); |
| 14 | + |
| 15 | +$productSku = 'simple'; |
| 16 | +$product = $productRepository->get($productSku); |
| 17 | +$product->setStatus(ProductStatus::STATUS_DISABLED); |
| 18 | +$productRepository->save($product); |
| 19 | + |
| 20 | +/** |
| 21 | + * We need to remember that automatic reindexation is not working properly in integration tests |
| 22 | + * Reindexation is sitting on top of afterCommit callbacks: |
| 23 | + * \Magento\Catalog\Model\Product::priceReindexCallback |
| 24 | + * |
| 25 | + * However, callbacks are applied only when transaction_level = 0 (when transaction is commited), however |
| 26 | + * integration tests are not committing transactions, so we need to reindex data manually in order to reuse it in tests |
| 27 | + */ |
| 28 | +/** @var \Magento\Indexer\Model\Indexer $indexer */ |
| 29 | +$indexer = \Magento\TestFramework\Helper\Bootstrap |
| 30 | + ::getObjectManager()->create(\Magento\Indexer\Model\Indexer::class); |
| 31 | +$indexer->load('catalog_product_price'); |
| 32 | +$indexer->reindexList([$product->getId()]); |
16 | 33 |
|
17 |
| -$objectManager = Bootstrap::getObjectManager(); |
18 |
| -/** @var CustomerRegistry $customerRegistry */ |
19 |
| -$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class); |
20 |
| -$customer = $customerRegistry->retrieve(1); |
21 |
| -/** @var ProductRepositoryInterface $productRepository */ |
22 |
| -$productRepository = $objectManager->create(ProductRepositoryInterface::class); |
23 |
| -$product = $productRepository->get('simple'); |
24 |
| -$wishlist = Bootstrap::getObjectManager()->create(Wishlist::class); |
25 |
| -$wishlist->loadByCustomerId($customer->getId(), true); |
26 |
| -$item = $wishlist->addNewItem($product, new DataObject([])); |
27 |
| -$wishlist->setSharingCode('fixture_unique_code')->save(); |
|
0 commit comments