From fd99ace7518c59f973ca5ec20636c58eb6d94e7d Mon Sep 17 00:00:00 2001 From: Serhii Kovalenko Date: Tue, 16 Jun 2020 18:27:01 +0300 Subject: [PATCH] [17] Read API :: Integration tests :: Customer* #55 --- .../two_wishlists_for_two_diff_customers.php | 13 +++++++++++++ .../testsuite/Magento/Wishlist/_files/wishlist.php | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php index 43285cea4cfd9..797dfef488e84 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php @@ -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()]); diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php index e578676e68e96..3cd71fe36ffe3 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php @@ -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()]); +