Skip to content

Commit 502cf20

Browse files
committed
MC-33459: Magento\Quote\Model\ShippingMethodManagementTest::testEstimateByAddressWithInclExclTaxAndVATGroup failed for 2.4-develop
1 parent 1e28f35 commit 502cf20

File tree

1 file changed

+45
-38
lines changed

1 file changed

+45
-38
lines changed

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

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Quote\Model;
87

98
use Magento\Customer\Api\AddressRepositoryInterface;
@@ -14,8 +13,12 @@
1413
use Magento\Customer\Model\Vat;
1514
use Magento\Framework\Api\SearchCriteriaBuilder;
1615
use Magento\Framework\App\Config\MutableScopeConfigInterface;
16+
use Magento\Framework\Exception\NoSuchEntityException;
1717
use Magento\Framework\ObjectManagerInterface;
1818
use Magento\Quote\Api\CartRepositoryInterface;
19+
use Magento\Quote\Api\Data\AddressInterfaceFactory;
20+
use Magento\Quote\Api\Data\EstimateAddressInterface;
21+
use Magento\Quote\Api\GuestShippingMethodManagementInterface;
1922
use Magento\Quote\Api\ShippingMethodManagementInterface;
2023
use Magento\Store\Model\ScopeInterface;
2124
use Magento\Tax\Api\Data\TaxClassInterface;
@@ -24,14 +27,15 @@
2427
use Magento\Tax\Model\Config as TaxConfig;
2528
use Magento\TestFramework\Helper\Bootstrap;
2629
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
30+
use PHPUnit\Framework\TestCase;
2731

2832
/**
2933
* Test for shipping methods management
3034
*
3135
* @magentoDbIsolation enabled
3236
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3337
*/
34-
class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase
38+
class ShippingMethodManagementTest extends TestCase
3539
{
3640
/** @var ObjectManagerInterface $objectManager */
3741
private $objectManager;
@@ -56,14 +60,14 @@ protected function setUp()
5660
* @magentoDataFixture Magento/SalesRule/_files/cart_rule_100_percent_off.php
5761
* @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
5862
* @return void
59-
* @throws \Magento\Framework\Exception\NoSuchEntityException
63+
* @throws NoSuchEntityException
6064
*/
6165
public function testRateAppliedToShipping(): void
6266
{
63-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
67+
$objectManager = Bootstrap::getObjectManager();
6468

65-
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
66-
$quoteRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class);
69+
/** @var CartRepositoryInterface $quoteRepository */
70+
$quoteRepository = $objectManager->create(CartRepositoryInterface::class);
6771
$customerQuote = $quoteRepository->getForCustomer(1);
6872
$this->assertEquals(0, $customerQuote->getBaseGrandTotal());
6973
}
@@ -80,17 +84,17 @@ public function testRateAppliedToShipping(): void
8084
*/
8185
public function testTableRateFreeShipping()
8286
{
83-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
84-
/** @var \Magento\Quote\Model\Quote $quote */
85-
$quote = $objectManager->get(\Magento\Quote\Model\Quote::class);
87+
$objectManager = Bootstrap::getObjectManager();
88+
/** @var Quote $quote */
89+
$quote = $objectManager->get(Quote::class);
8690
$quote->load('test01', 'reserved_order_id');
8791
$cartId = $quote->getId();
8892
if (!$cartId) {
8993
$this->fail('quote fixture failed');
9094
}
91-
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
92-
$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
93-
->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
95+
/** @var QuoteIdMask $quoteIdMask */
96+
$quoteIdMask = Bootstrap::getObjectManager()
97+
->create(QuoteIdMaskFactory::class)
9498
->create();
9599
$quoteIdMask->load($cartId, 'quote_id');
96100
//Use masked cart Id
@@ -103,10 +107,10 @@ public function testTableRateFreeShipping()
103107
'region_id' => null
104108
]
105109
];
106-
/** @var \Magento\Quote\Api\Data\EstimateAddressInterface $address */
107-
$address = $objectManager->create(\Magento\Quote\Api\Data\EstimateAddressInterface::class, $data);
108-
/** @var \Magento\Quote\Api\GuestShippingMethodManagementInterface $shippingEstimation */
109-
$shippingEstimation = $objectManager->get(\Magento\Quote\Api\GuestShippingMethodManagementInterface::class);
110+
/** @var EstimateAddressInterface $address */
111+
$address = $objectManager->create(EstimateAddressInterface::class, $data);
112+
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
113+
$shippingEstimation = $objectManager->get(GuestShippingMethodManagementInterface::class);
110114
$result = $shippingEstimation->estimateByAddress($cartId, $address);
111115
$this->assertNotEmpty($result);
112116
$expectedResult = [
@@ -134,25 +138,25 @@ public function testTableRateFreeShipping()
134138
*/
135139
public function testTableRateWithCartRuleForFreeShipping()
136140
{
137-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
141+
$objectManager = Bootstrap::getObjectManager();
138142
$quote = $this->getQuote('tableRate');
139143
$cartId = $quote->getId();
140144
if (!$cartId) {
141145
$this->fail('quote fixture failed');
142146
}
143-
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
144-
$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
145-
->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
147+
/** @var QuoteIdMask $quoteIdMask */
148+
$quoteIdMask = Bootstrap::getObjectManager()
149+
->create(QuoteIdMaskFactory::class)
146150
->create();
147151
$quoteIdMask->load($cartId, 'quote_id');
148152
//Use masked cart Id
149153
$cartId = $quoteIdMask->getMaskedId();
150-
$addressFactory = $this->objectManager->get(\Magento\Quote\Api\Data\AddressInterfaceFactory::class);
154+
$addressFactory = $this->objectManager->get(AddressInterfaceFactory::class);
151155
/** @var \Magento\Quote\Api\Data\AddressInterface $address */
152156
$address = $addressFactory->create();
153157
$address->setCountryId('US');
154-
/** @var \Magento\Quote\Api\GuestShippingMethodManagementInterface $shippingEstimation */
155-
$shippingEstimation = $objectManager->get(\Magento\Quote\Api\GuestShippingMethodManagementInterface::class);
158+
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
159+
$shippingEstimation = $objectManager->get(GuestShippingMethodManagementInterface::class);
156160
$result = $shippingEstimation->estimateByExtendedAddress($cartId, $address);
157161
$this->assertCount(1, $result);
158162
$rate = reset($result);
@@ -234,17 +238,17 @@ public function testEstimateByAddress()
234238
*/
235239
private function executeTestFlow($flatRateAmount, $tableRateAmount)
236240
{
237-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
238-
/** @var \Magento\Quote\Model\Quote $quote */
239-
$quote = $objectManager->get(\Magento\Quote\Model\Quote::class);
241+
$objectManager = Bootstrap::getObjectManager();
242+
/** @var Quote $quote */
243+
$quote = $objectManager->get(Quote::class);
240244
$quote->load('test01', 'reserved_order_id');
241245
$cartId = $quote->getId();
242246
if (!$cartId) {
243247
$this->fail('quote fixture failed');
244248
}
245-
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
246-
$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
247-
->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
249+
/** @var QuoteIdMask $quoteIdMask */
250+
$quoteIdMask = Bootstrap::getObjectManager()
251+
->create(QuoteIdMaskFactory::class)
248252
->create();
249253
$quoteIdMask->load($cartId, 'quote_id');
250254
//Use masked cart Id
@@ -257,17 +261,17 @@ private function executeTestFlow($flatRateAmount, $tableRateAmount)
257261
'region_id' => null
258262
]
259263
];
260-
/** @var \Magento\Quote\Api\Data\EstimateAddressInterface $address */
261-
$address = $objectManager->create(\Magento\Quote\Api\Data\EstimateAddressInterface::class, $data);
262-
/** @var \Magento\Quote\Api\GuestShippingMethodManagementInterface $shippingEstimation */
263-
$shippingEstimation = $objectManager->get(\Magento\Quote\Api\GuestShippingMethodManagementInterface::class);
264+
/** @var EstimateAddressInterface $address */
265+
$address = $objectManager->create(EstimateAddressInterface::class, $data);
266+
/** @var GuestShippingMethodManagementInterface $shippingEstimation */
267+
$shippingEstimation = $objectManager->get(GuestShippingMethodManagementInterface::class);
264268
$result = $shippingEstimation->estimateByAddress($cartId, $address);
265269
$this->assertNotEmpty($result);
266270
$expectedResult = [
267271
'tablerate' => [
268-
'method_code' => 'bestway',
269-
'amount' => $tableRateAmount
270-
],
272+
'method_code' => 'bestway',
273+
'amount' => $tableRateAmount
274+
],
271275
'flatrate' => [
272276
'method_code' => 'flatrate',
273277
'amount' => $flatRateAmount
@@ -295,8 +299,6 @@ private function executeTestFlow($flatRateAmount, $tableRateAmount)
295299
*/
296300
public function testEstimateByAddressWithInclExclTaxAndVATGroup()
297301
{
298-
$this->markTestSkipped('MC-33463');
299-
300302
/** @var CustomerRepositoryInterface $customerRepository */
301303
$customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class);
302304
$customer = $customerRepository->get('[email protected]');
@@ -395,6 +397,11 @@ private function setConfig(int $customerGroupId, int $productTaxClassId): void
395397
'value' => $customerGroupId,
396398
'scope' => ScopeInterface::SCOPE_STORE,
397399
],
400+
[
401+
'path' => Vat::XML_PATH_CUSTOMER_VIV_ERROR_GROUP,
402+
'value' => $customerGroupId,
403+
'scope' => ScopeInterface::SCOPE_STORE,
404+
],
398405
[
399406
'path' => TaxConfig::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
400407
'value' => $productTaxClassId,

0 commit comments

Comments
 (0)