Skip to content

Commit 953f776

Browse files
committed
[TASK] - Reworked on Integration tests to fix newly introduced legacy static test failures
1 parent c61c9b9 commit 953f776

File tree

3 files changed

+27
-159
lines changed

3 files changed

+27
-159
lines changed

dev/tests/integration/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use Magento\Tax\Api\TaxClassRepositoryInterface;
2828
use Magento\Tax\Model\ClassModel;
2929
use Magento\Tax\Model\Config as TaxConfig;
30+
use Magento\TestFramework\Fixture\DataFixtureStorage;
31+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
3032
use Magento\TestFramework\Helper\Bootstrap;
3133
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
3234
use PHPUnit\Framework\TestCase;
@@ -48,6 +50,11 @@ class ShippingMethodManagementTest extends TestCase
4850
/** @var TaxClassRepositoryInterface $taxClassRepository */
4951
private $taxClassRepository;
5052

53+
/**
54+
* @var DataFixtureStorage
55+
*/
56+
private $fixtures;
57+
5158
/**
5259
* @inheritdoc
5360
*/
@@ -56,6 +63,7 @@ protected function setUp(): void
5663
$this->objectManager = Bootstrap::getObjectManager();
5764
$this->groupRepository = $this->objectManager->get(GroupRepositoryInterface::class);
5865
$this->taxClassRepository = $this->objectManager->get(TaxClassRepositoryInterface::class);
66+
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
5967
}
6068

6169
/**
@@ -126,33 +134,42 @@ public function testTableRateFreeShipping()
126134
}
127135

128136
/**
137+
* phpcs:disable Generic.Files.LineLength.TooLong
138+
*
129139
* @magentoConfigFixture default_store carriers/tablerate/active 1
130140
* @magentoConfigFixture default_store carriers/flatrate/active 0
131141
* @magentoConfigFixture current_store carriers/tablerate/condition_name package_value_with_discount
132142
* @magentoConfigFixture default_store carriers/tablerate/include_virtual_price 0
133-
* @magentoDataFixture Magento/Sales/_files/quote_with_simple_and_virtual_product.php
143+
* @magentoDataFixture Magento\Catalog\Test\Fixture\Product with:{"sku":"simple", "type_id":"simple"} as:p1
144+
* @magentoDataFixture Magento\Catalog\Test\Fixture\Product with:{"sku":"virtual", "type_id":"virtual", "weight":0} as:p2
145+
* @magentoDataFixture Magento\Quote\Test\Fixture\GuestCart as:cart
146+
* @magentoDataFixture Magento\Quote\Test\Fixture\AddProductToCart with:{"cart_id":"$cart.id$", "product_id":"$p1.id$"}
147+
* @magentoDataFixture Magento\Quote\Test\Fixture\AddProductToCart with:{"cart_id":"$cart.id$", "product_id":"$p2.id$"}
148+
* @magentoDataFixture Magento\Quote\Test\Fixture\SetBillingAddress with:{"cart_id":"$cart.id$"}
149+
* @magentoDataFixture Magento\Quote\Test\Fixture\SetShippingAddress with:{"cart_id":"$cart.id$"}
134150
* @magentoDataFixture Magento/OfflineShipping/_files/tablerates_price.php
135151
* @return void
152+
* @throws NoSuchEntityException
136153
*/
137154
public function testTableRateWithoutIncludingVirtualProduct()
138155
{
139-
$quote = $this->getQuote('quoteWithVirtualProduct');
140-
$cartId = $quote->getId();
156+
$cartId = (int)$this->fixtures->get('cart')->getId();
141157

142158
if (!$cartId) {
143159
$this->fail('quote fixture failed');
144160
}
145161

146-
/** @var QuoteIdMask $quoteIdMask */
147-
$quoteIdMask = $this->objectManager
148-
->create(QuoteIdMaskFactory::class)
149-
->create()
150-
->load($cartId, 'quote_id');
162+
/** @var QuoteRepository $quoteRepository */
163+
$quoteRepository = $this->objectManager->get(QuoteRepository::class);
164+
$quote = $quoteRepository->get($cartId);
151165

152-
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
166+
/** @var QuoteIdToMaskedQuoteIdInterface $maskedQuoteId */
167+
$maskedQuoteId = $this->objectManager->get(QuoteIdToMaskedQuoteIdInterface::class)->execute($cartId);
168+
169+
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
153170
$shippingEstimation = $this->objectManager->get(GuestShippingMethodManagementInterface::class);
154171
$result = $shippingEstimation->estimateByExtendedAddress(
155-
$quoteIdMask->getMaskedId(),
172+
$maskedQuoteId,
156173
$quote->getShippingAddress()
157174
);
158175

dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_simple_and_virtual_product.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_simple_and_virtual_product_rollback.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)