Skip to content

Commit 7657283

Browse files
committed
Fixed Failing integration test
1 parent 4e85f7e commit 7657283

File tree

1 file changed

+69
-68
lines changed

1 file changed

+69
-68
lines changed

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

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -79,73 +79,7 @@ protected function setUp(): void
7979
}
8080

8181
/**
82-
* @magentoDataFixture Magento/SalesRule/_files/cart_rule_100_percent_off.php
83-
* @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
84-
* @return void
85-
* @throws NoSuchEntityException
86-
*/
87-
public function testRateAppliedToShipping(): void
88-
{
89-
$objectManager = Bootstrap::getObjectManager();
90-
91-
/** @var CartRepositoryInterface $quoteRepository */
92-
$quoteRepository = $objectManager->create(CartRepositoryInterface::class);
93-
$customerQuote = $quoteRepository->getForCustomer(1);
94-
$this->assertEquals(0, $customerQuote->getBaseGrandTotal());
95-
}
96-
97-
/**
98-
* @magentoConfigFixture current_store carriers/tablerate/active 1
99-
* @magentoConfigFixture current_store carriers/flatrate/active 0
100-
* @magentoConfigFixture current_store carriers/freeshipping/active 0
101-
* @magentoConfigFixture current_store carriers/tablerate/condition_name package_qty
102-
* @magentoDataFixture Magento/SalesRule/_files/cart_rule_free_shipping_by_cart.php
103-
* @magentoDataFixture Magento/Sales/_files/quote.php
104-
* @magentoDataFixture Magento/OfflineShipping/_files/tablerates.php
105-
* @return void
106-
*/
107-
public function testTableRateFreeShipping()
108-
{
109-
$objectManager = Bootstrap::getObjectManager();
110-
/** @var Quote $quote */
111-
$quote = $objectManager->get(Quote::class);
112-
$quote->load('test01', 'reserved_order_id');
113-
$cartId = $quote->getId();
114-
if (!$cartId) {
115-
$this->fail('quote fixture failed');
116-
}
117-
/** @var QuoteIdMask $quoteIdMask */
118-
$quoteIdMask = Bootstrap::getObjectManager()
119-
->create(QuoteIdMaskFactory::class)
120-
->create();
121-
$quoteIdMask->load($cartId, 'quote_id');
122-
//Use masked cart Id
123-
$cartId = $quoteIdMask->getMaskedId();
124-
$data = [
125-
'data' => [
126-
'country_id' => "US",
127-
'postcode' => null,
128-
'region' => null,
129-
'region_id' => null
130-
]
131-
];
132-
/** @var EstimateAddressInterface $address */
133-
$address = $objectManager->create(EstimateAddressInterface::class, $data);
134-
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
135-
$shippingEstimation = $objectManager->get(GuestShippingMethodManagementInterface::class);
136-
$result = $shippingEstimation->estimateByAddress($cartId, $address);
137-
$this->assertNotEmpty($result);
138-
$expectedResult = [
139-
'method_code' => 'bestway',
140-
'amount' => 0
141-
];
142-
foreach ($result as $rate) {
143-
$this->assertEquals($expectedResult['amount'], $rate->getAmount());
144-
$this->assertEquals($expectedResult['method_code'], $rate->getMethodCode());
145-
}
146-
}
147-
148-
/**
82+
* @magentoDbIsolation enabled
14983
* @magentoDataFixture Magento/OfflineShipping/_files/tablerates_price.php
15084
* @return void
15185
* @throws NoSuchEntityException
@@ -197,7 +131,7 @@ public function testTableRateWithoutIncludingVirtualProduct()
197131

198132
/**
199133
* Test table rate amount for the cart that contains some items with free shipping applied.
200-
*
134+
* @magentoDbIsolation enabled
201135
* @magentoConfigFixture current_store carriers/tablerate/active 1
202136
* @magentoConfigFixture current_store carriers/flatrate/active 0
203137
* @magentoConfigFixture current_store carriers/freeshipping/active 0
@@ -239,6 +173,73 @@ public function testTableRateWithCartRuleForFreeShipping()
239173
$this->assertEquals($expectedResult['method_code'], $rate->getMethodCode());
240174
$this->assertEquals($expectedResult['amount'], $rate->getAmount());
241175
}
176+
177+
/**
178+
* @magentoDataFixture Magento/SalesRule/_files/cart_rule_100_percent_off.php
179+
* @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
180+
* @return void
181+
* @throws NoSuchEntityException
182+
*/
183+
public function testRateAppliedToShipping(): void
184+
{
185+
$objectManager = Bootstrap::getObjectManager();
186+
187+
/** @var CartRepositoryInterface $quoteRepository */
188+
$quoteRepository = $objectManager->create(CartRepositoryInterface::class);
189+
$customerQuote = $quoteRepository->getForCustomer(1);
190+
$this->assertEquals(0, $customerQuote->getBaseGrandTotal());
191+
}
192+
193+
/**
194+
* @magentoConfigFixture current_store carriers/tablerate/active 1
195+
* @magentoConfigFixture current_store carriers/flatrate/active 0
196+
* @magentoConfigFixture current_store carriers/freeshipping/active 0
197+
* @magentoConfigFixture current_store carriers/tablerate/condition_name package_qty
198+
* @magentoDataFixture Magento/SalesRule/_files/cart_rule_free_shipping_by_cart.php
199+
* @magentoDataFixture Magento/Sales/_files/quote.php
200+
* @magentoDataFixture Magento/OfflineShipping/_files/tablerates.php
201+
* @return void
202+
*/
203+
public function testTableRateFreeShipping()
204+
{
205+
$objectManager = Bootstrap::getObjectManager();
206+
/** @var Quote $quote */
207+
$quote = $objectManager->get(Quote::class);
208+
$quote->load('test01', 'reserved_order_id');
209+
$cartId = $quote->getId();
210+
if (!$cartId) {
211+
$this->fail('quote fixture failed');
212+
}
213+
/** @var QuoteIdMask $quoteIdMask */
214+
$quoteIdMask = Bootstrap::getObjectManager()
215+
->create(QuoteIdMaskFactory::class)
216+
->create();
217+
$quoteIdMask->load($cartId, 'quote_id');
218+
//Use masked cart Id
219+
$cartId = $quoteIdMask->getMaskedId();
220+
$data = [
221+
'data' => [
222+
'country_id' => "US",
223+
'postcode' => null,
224+
'region' => null,
225+
'region_id' => null
226+
]
227+
];
228+
/** @var EstimateAddressInterface $address */
229+
$address = $objectManager->create(EstimateAddressInterface::class, $data);
230+
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
231+
$shippingEstimation = $objectManager->get(GuestShippingMethodManagementInterface::class);
232+
$result = $shippingEstimation->estimateByAddress($cartId, $address);
233+
$this->assertNotEmpty($result);
234+
$expectedResult = [
235+
'method_code' => 'bestway',
236+
'amount' => 0
237+
];
238+
foreach ($result as $rate) {
239+
$this->assertEquals($expectedResult['amount'], $rate->getAmount());
240+
$this->assertEquals($expectedResult['method_code'], $rate->getMethodCode());
241+
}
242+
}
242243

243244
/**
244245
* Retrieves quote by reserved order id.

0 commit comments

Comments
 (0)