Skip to content

Commit

Permalink
[17] Read API :: Integration tests :: Customer* #55
Browse files Browse the repository at this point in the history
  • Loading branch information
skovalenk authored and le0n4ik committed Aug 3, 2020
1 parent 716b98a commit fd99ace
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@
$wishlistForSecondCustomer->loadByCustomerId($secondCustomerIdFromFixture, true);
$item = $wishlistForSecondCustomer->addNewItem($product, new \Magento\Framework\DataObject([]));
$wishlistForSecondCustomer->save();

/**
* We need to remember that automatic reindexation is not working properly in integration tests
* Reindexation is sitting on top of afterCommit callbacks:
* \Magento\Catalog\Model\Product::priceReindexCallback
*
* However, callbacks are applied only when transaction_level = 0 (when transaction is commited), however
* integration tests are not committing transactions, so we need to reindex data manually in order to reuse it in tests
*/
/** @var \Magento\Indexer\Model\Indexer $indexer */
$indexer = Bootstrap::getObjectManager()->create(\Magento\Indexer\Model\Indexer::class);
$indexer->load('catalog_product_price');
$indexer->reindexList([$product->getId()]);
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@
$wishlist->loadByCustomerId($customer->getId(), true);
$item = $wishlist->addNewItem($product, new DataObject([]));
$wishlist->setSharingCode('fixture_unique_code')->save();

/**
* We need to remember that automatic reindexation is not working properly in integration tests
* Reindexation is sitting on top of afterCommit callbacks:
* \Magento\Catalog\Model\Product::priceReindexCallback
*
* However, callbacks are applied only when transaction_level = 0 (when transaction is commited), however
* integration tests are not committing transactions, so we need to reindex data manually in order to reuse it in tests
*/
/** @var \Magento\Indexer\Model\Indexer $indexer */
$indexer = Bootstrap::getObjectManager()->create(\Magento\Indexer\Model\Indexer::class);
$indexer->load('catalog_product_price');
$indexer->reindexList([$product->getId()]);

0 comments on commit fd99ace

Please sign in to comment.