Skip to content

Commit 315a517

Browse files
authored
Merge pull request #7725 from magento-gl/245_new_regression_issue
2.4.5-regression-issue
2 parents 1b0d39e + 1af6d50 commit 315a517

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

app/code/Magento/Quote/Model/Quote.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Quote\Model;
77

8+
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
89
use Magento\Customer\Api\Data\CustomerInterface;
910
use Magento\Customer\Api\Data\GroupInterface;
1011
use Magento\Directory\Model\AllowedCountries;
@@ -874,7 +875,8 @@ public function beforeSave()
874875
* Loading quote data by customer
875876
*
876877
* @param \Magento\Customer\Model\Customer|int $customer
877-
* @deprecated 101.0.0
878+
* @deprecated 101.0.0 Deprecated to handle external usages of customer methods
879+
* @see https://jira.corp.magento.com/browse/MAGETWO-19935
878880
* @return $this
879881
*/
880882
public function loadByCustomer($customer)
@@ -1427,12 +1429,14 @@ public function getItemsCollection($useCache = true)
14271429
public function getAllItems()
14281430
{
14291431
$items = [];
1432+
/** @var \Magento\Quote\Model\Quote\Item $item */
14301433
foreach ($this->getItemsCollection() as $item) {
1431-
/** @var \Magento\Quote\Model\Quote\Item $item */
1432-
if (!$item->isDeleted()) {
1434+
$product = $item->getProduct();
1435+
if (!$item->isDeleted() && ($product && (int)$product->getStatus() !== ProductStatus::STATUS_DISABLED)) {
14331436
$items[] = $item;
14341437
}
14351438
}
1439+
14361440
return $items;
14371441
}
14381442

app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,9 @@ public function testAddProductItemPreparation(): void
10341034
$itemMock->expects($this->any())
10351035
->method('representProduct')
10361036
->willReturn(true);
1037+
$itemMock->expects($this->any())
1038+
->method('getProduct')
1039+
->willReturn($this->productMock);
10371040

10381041
$iterator = new \ArrayIterator([$itemMock]);
10391042
$collectionMock->expects($this->any())
@@ -1402,20 +1405,26 @@ public function testGetItemsCollection(): void
14021405
public function testGetAllItems(): void
14031406
{
14041407
$itemOneMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Item::class)
1405-
->addMethods(['isDeleted'])
1408+
->addMethods(['isDeleted', 'getProduct'])
14061409
->disableOriginalConstructor()
14071410
->getMock();
14081411
$itemOneMock->expects($this->once())
14091412
->method('isDeleted')
14101413
->willReturn(false);
1414+
$itemOneMock->expects($this->once())
1415+
->method('getProduct')
1416+
->willReturn($this->productMock);
14111417

14121418
$itemTwoMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Item::class)
1413-
->addMethods(['isDeleted'])
1419+
->addMethods(['isDeleted', 'getProduct'])
14141420
->disableOriginalConstructor()
14151421
->getMock();
14161422
$itemTwoMock->expects($this->once())
14171423
->method('isDeleted')
14181424
->willReturn(true);
1425+
$itemTwoMock->expects($this->once())
1426+
->method('getProduct')
1427+
->willReturn($this->productMock);
14191428

14201429
$items = [$itemOneMock, $itemTwoMock];
14211430
$itemResult = [$itemOneMock];

app/code/Magento/Reports/Test/Mftf/Test/AdminCanceledOrdersInOrderSalesReportTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</annotations>
2222

2323
<before>
24+
<!--Enable flat rate shipping-->
25+
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
2426
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
2527

2628
<createData entity="_defaultCategory" stepKey="createCategory"/>
@@ -72,6 +74,8 @@
7274
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
7375
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
7476
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
77+
<!-- Disable shipping method for customer with default address -->
78+
<magentoCLI command="config:set {{DisableFlatRateConfigData.path}} {{DisableFlatRateConfigData.value}}" stepKey="disableFlatRate"/>
7579
</after>
7680

7781
<actionGroup ref="AdminGoToOrdersReportPageActionGroup" stepKey="goToOrdersReportPage1"/>

app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderForCustomerWithTwoAddressesTaxableAndNonTaxableTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
7575
<!--Disable free shipping method -->
7676
<magentoCLI command="config:set {{DisableFreeShippingConfigData.path}} {{DisableFreeShippingConfigData.value}}" stepKey="disableFreeShipping"/>
77+
<!-- Disable shipping method for customer with default address -->
78+
<magentoCLI command="config:set {{DisableFlatRateConfigData.path}} {{DisableFlatRateConfigData.value}}" stepKey="disableFlatRate"/>
7779
</after>
7880
</test>
7981
</tests>

dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Dhl\Model;
99

1010
use Magento\Framework\App\Config\ReinitableConfigInterface;
11+
use Magento\Framework\App\ProductMetadataInterface;
1112
use Magento\Framework\DataObject;
1213
use Magento\Framework\HTTP\AsyncClient\HttpException;
1314
use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface;
@@ -48,6 +49,11 @@ class CarrierTest extends TestCase
4849
*/
4950
private $config;
5051

52+
/**
53+
* @var ProductMetadataInterface
54+
*/
55+
private $productMetadata;
56+
5157
/**
5258
* @var string
5359
*/
@@ -62,6 +68,7 @@ protected function setUp(): void
6268
$this->dhlCarrier = $objectManager->get(Carrier::class);
6369
$this->httpClient = $objectManager->get(AsyncClientInterface::class);
6470
$this->config = $objectManager->get(ReinitableConfigInterface::class);
71+
$this->productMetadata = $objectManager->get(ProductMetadataInterface::class);
6572
$this->restoreCountry = $this->config->getValue('shipping/origin/country_id', 'store', 'default_store');
6673
}
6774

@@ -402,6 +409,7 @@ private function getExpectedLabelRequestXml(
402409
// phpcs:ignore Magento2.Functions.DiscouragedFunction
403410
$expectedRequestElement = new ShippingElement(file_get_contents(__DIR__ . $requestXmlPath));
404411

412+
$expectedRequestElement->Request->MetaData->SoftwareVersion = $this->buildSoftwareVersion();
405413
$expectedRequestElement->Consignee->CountryCode = $destCountryId;
406414
$expectedRequestElement->Consignee->CountryName = $countryNames[$destCountryId];
407415
$expectedRequestElement->Shipper->CountryCode = $origCountryId;
@@ -415,6 +423,16 @@ private function getExpectedLabelRequestXml(
415423
return $expectedRequestElement->asXML();
416424
}
417425

426+
/**
427+
* Builds a string to be used as the request SoftwareVersion.
428+
*
429+
* @return string
430+
*/
431+
private function buildSoftwareVersion(): string
432+
{
433+
return substr($this->productMetadata->getVersion(), 0, 10);
434+
}
435+
418436
/**
419437
* Tests that valid rates are returned when sending a quotes request.
420438
*

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*
3535
* @see \Magento\Quote\Model\QuoteManagement
3636
* @magentoDbIsolation enabled
37+
* @magentoAppIsolation enabled
3738
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3839
*/
3940
class QuoteManagementTest extends TestCase
@@ -196,7 +197,6 @@ public function testSubmitWithDeletedItem(): void
196197
$this->cartManagement->placeOrder($quote->getId());
197198
}
198199

199-
200200
/**
201201
* Tries to create order with product that has child items and one of them
202202
* was deleted when item data check is disabled on quote load.
@@ -237,7 +237,11 @@ public function testSubmitWithItemOutOfStockWithDisabledInventoryCheck(): void
237237
{
238238
$this->makeProductOutOfStock('simple');
239239
$quote = $this->getQuoteByReservedOrderId->execute('test01');
240-
$this->expectExceptionObject(new LocalizedException(__('The shipping method is missing. Select the shipping method and try again.')));
240+
$this->expectExceptionObject(
241+
new LocalizedException(
242+
__('The shipping method is missing. Select the shipping method and try again.')
243+
)
244+
);
241245
$this->cartManagement->placeOrder($quote->getId());
242246
}
243247

0 commit comments

Comments
 (0)