Skip to content

Commit fd99ace

Browse files
skovalenkle0n4ik
authored andcommitted
[17] Read API :: Integration tests :: Customer* #55
1 parent 716b98a commit fd99ace

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

dev/tests/integration/testsuite/Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,16 @@
3131
$wishlistForSecondCustomer->loadByCustomerId($secondCustomerIdFromFixture, true);
3232
$item = $wishlistForSecondCustomer->addNewItem($product, new \Magento\Framework\DataObject([]));
3333
$wishlistForSecondCustomer->save();
34+
35+
/**
36+
* We need to remember that automatic reindexation is not working properly in integration tests
37+
* Reindexation is sitting on top of afterCommit callbacks:
38+
* \Magento\Catalog\Model\Product::priceReindexCallback
39+
*
40+
* However, callbacks are applied only when transaction_level = 0 (when transaction is commited), however
41+
* integration tests are not committing transactions, so we need to reindex data manually in order to reuse it in tests
42+
*/
43+
/** @var \Magento\Indexer\Model\Indexer $indexer */
44+
$indexer = Bootstrap::getObjectManager()->create(\Magento\Indexer\Model\Indexer::class);
45+
$indexer->load('catalog_product_price');
46+
$indexer->reindexList([$product->getId()]);

dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@
2525
$wishlist->loadByCustomerId($customer->getId(), true);
2626
$item = $wishlist->addNewItem($product, new DataObject([]));
2727
$wishlist->setSharingCode('fixture_unique_code')->save();
28+
29+
/**
30+
* We need to remember that automatic reindexation is not working properly in integration tests
31+
* Reindexation is sitting on top of afterCommit callbacks:
32+
* \Magento\Catalog\Model\Product::priceReindexCallback
33+
*
34+
* However, callbacks are applied only when transaction_level = 0 (when transaction is commited), however
35+
* integration tests are not committing transactions, so we need to reindex data manually in order to reuse it in tests
36+
*/
37+
/** @var \Magento\Indexer\Model\Indexer $indexer */
38+
$indexer = Bootstrap::getObjectManager()->create(\Magento\Indexer\Model\Indexer::class);
39+
$indexer->load('catalog_product_price');
40+
$indexer->reindexList([$product->getId()]);
41+

0 commit comments

Comments
 (0)