Skip to content

Commit 51a5829

Browse files
authored
Merge branch '2.4-develop' into comprs_v2
2 parents 72a8604 + 1366ae5 commit 51a5829

File tree

32 files changed

+918
-259
lines changed

32 files changed

+918
-259
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66

77
/**
@@ -392,8 +392,7 @@ protected function _getNodeJson($node, $level = 0)
392392
$item['id'] = $node->getId();
393393
$item['store'] = (int)$this->getStore()->getId();
394394
$item['path'] = $node->getData('path');
395-
396-
$item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
395+
$item['a_attr'] = ['class' => $node->getIsActive() ? 'active-category' : 'not-active-category'];
397396
//$item['allowDrop'] = ($level<3) ? true : false;
398397
$allowMove = $this->_isCategoryMoveable($node);
399398
$item['allowDrop'] = $allowMove;

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -182,7 +182,7 @@ private function formatTierPrices(float $productPrice, string $currencyCode, $ti
182182
"discount" => $discount,
183183
"quantity" => $tierPrice->getQty(),
184184
"final_price" => [
185-
"value" => $tierPrice->getValue() * $tierPrice->getQty(),
185+
"value" => $tierPrice->getValue(),
186186
"currency" => $currencyCode
187187
]
188188
];

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\CatalogSearch\Model\Indexer;
@@ -123,7 +123,7 @@ public function __construct(
123123
IndexSwitcherInterface $indexSwitcher,
124124
StateFactory $indexScopeStateFactory,
125125
DimensionProviderInterface $dimensionProvider,
126-
array $data,
126+
array $data = [],
127127
ProcessManager $processManager = null,
128128
?int $batchSize = null,
129129
?DeploymentConfig $deploymentConfig = null

app/code/Magento/Customer/Helper/View.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Customer\Helper;
77

@@ -68,6 +68,6 @@ public function getCustomerName(CustomerInterface $customerData)
6868
$name .= ' ' . __($customerData->getSuffix());
6969
}
7070

71-
return $this->escaper->escapeHtml($name);
71+
return $name;
7272
}
7373
}

app/code/Magento/Customer/Model/Address/Validator/Customer.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -44,10 +44,7 @@ public function validate(AbstractAddress $address): array
4444
->getCustomerId();
4545

4646
if ($originalAddressCustomerId !== 0 && $originalAddressCustomerId !== $addressCustomerId) {
47-
$errors[] = __(
48-
'Provided customer ID "%customer_id" isn\'t related to current customer address.',
49-
['customer_id' => $addressCustomerId]
50-
);
47+
$errors[] = __('A customer with the same email address already exists in an associated website.');
5148
}
5249
}
5350

app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -54,9 +54,7 @@ protected function setUp(): void
5454
*/
5555
public function testGetCustomerName($prefix, $firstName, $middleName, $lastName, $suffix, $result)
5656
{
57-
$customerData = $this->getMockBuilder(CustomerInterface::class)
58-
->disableOriginalConstructor()
59-
->getMockForAbstractClass();
57+
$customerData = $this->createMock(CustomerInterface::class);
6058
$customerData->expects($this->any())
6159
->method('getPrefix')->willReturn($prefix);
6260
$customerData->expects($this->any())
@@ -67,7 +65,7 @@ public function testGetCustomerName($prefix, $firstName, $middleName, $lastName,
6765
->method('getLastname')->willReturn($lastName);
6866
$customerData->expects($this->any())
6967
->method('getSuffix')->willReturn($suffix);
70-
$this->escaperMock->expects($this->once())->method('escapeHtml')->with($result)->willReturn($result);
68+
$this->escaperMock->expects(self::never())->method('escapeHtml');
7169
$this->assertEquals($result, $this->object->getCustomerName($customerData));
7270
}
7371

app/code/Magento/Customer/Test/Unit/Model/Address/Validator/CustomerTest.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -82,12 +82,7 @@ public function testValidateNewCustomerWithExistingCustomerAddress(): void
8282
$originalAddressMock->expects($this->once())->method('getCustomerId')->willReturn(2);
8383

8484
$this->assertEquals(
85-
[
86-
__(
87-
'Provided customer ID "%customer_id" isn\'t related to current customer address.',
88-
['customer_id' => null]
89-
)
90-
],
85+
[__('A customer with the same email address already exists in an associated website.')],
9186
$this->model->validate($addressMock)
9287
);
9388
}
@@ -160,12 +155,7 @@ public function testValidateExistingCustomerAddressWithNotRelevantCustomer(): vo
160155
$originalAddressMock->expects($this->once())->method('getCustomerId')->willReturn(1);
161156

162157
$this->assertEquals(
163-
[
164-
__(
165-
'Provided customer ID "%customer_id" isn\'t related to current customer address.',
166-
['customer_id' => 2]
167-
)
168-
],
158+
[__('A customer with the same email address already exists in an associated website.')],
169159
$this->model->validate($addressMock)
170160
);
171161
}

app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Customer\Test\Unit\Model\ResourceModel\Db\VersionControl;
99

1010
use Magento\Customer\Model\ResourceModel\Db\VersionControl\AddressSnapshot;
1111
use Magento\Framework\DataObject;
12+
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata;
14+
use Magento\Framework\Serialize\SerializerInterface;
1315
use PHPUnit\Framework\MockObject\MockObject;
1416
use PHPUnit\Framework\TestCase;
1517

@@ -18,22 +20,30 @@ class AddressSnapshotTest extends TestCase
1820
/**
1921
* @var AddressSnapshot
2022
*/
21-
private $model;
23+
private AddressSnapshot $model;
2224

2325
/**
2426
* @var Metadata|MockObject
2527
*/
26-
private $metadataMock;
28+
private Metadata $metadataMock;
2729

30+
/**
31+
* @var SerializerInterface|MockObject
32+
*/
33+
private SerializerInterface $serializer;
34+
35+
/**
36+
* @return void
37+
* @throws \PHPUnit\Framework\MockObject\Exception
38+
*/
2839
protected function setUp(): void
2940
{
30-
$this->metadataMock = $this->getMockBuilder(
31-
Metadata::class
32-
)->disableOriginalConstructor()
33-
->getMock();
41+
$this->metadataMock = $this->createMock(Metadata::class);
42+
$this->serializer = $this->createMock(SerializerInterface::class);
3443

3544
$this->model = new AddressSnapshot(
36-
$this->metadataMock
45+
$this->metadataMock,
46+
$this->serializer
3747
);
3848
}
3949

@@ -43,13 +53,10 @@ protected function setUp(): void
4353
* @param int $isDefaultShipping
4454
* @param bool $expected
4555
* @dataProvider dataProviderIsModified
56+
* @throws LocalizedException
4657
*/
47-
public function testIsModified(
48-
$isCustomerSaveTransaction,
49-
$isDefaultBilling,
50-
$isDefaultShipping,
51-
$expected
52-
) {
58+
public function testIsModified($isCustomerSaveTransaction, $isDefaultBilling, $isDefaultShipping, $expected): void
59+
{
5360
$entityId = 1;
5461

5562
$dataObjectMock = $this->getMockBuilder(DataObject::class)
@@ -96,7 +103,7 @@ public function testIsModified(
96103
/**
97104
* @return array
98105
*/
99-
public static function dataProviderIsModified()
106+
public static function dataProviderIsModified(): array
100107
{
101108
return [
102109
[false, 1, 1, true],
@@ -106,7 +113,11 @@ public static function dataProviderIsModified()
106113
];
107114
}
108115

109-
public function testIsModifiedBypass()
116+
/**
117+
* @return void
118+
* @throws LocalizedException
119+
*/
120+
public function testIsModifiedBypass(): void
110121
{
111122
$dataObjectMock = $this->getMockBuilder(DataObject::class)
112123
->disableOriginalConstructor()

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Quote\Model;
@@ -14,7 +14,6 @@
1414
use Magento\Quote\Model\Quote as QuoteEntity;
1515
use Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage as OrderAmountValidationMessage;
1616
use Magento\Quote\Model\ValidationRules\QuoteValidationRuleInterface;
17-
use Magento\Framework\Webapi\Rest\Response as RestResponse;
1817

1918
/**
2019
* Class to validate the quote
@@ -44,32 +43,24 @@ class QuoteValidator
4443
*/
4544
private $quoteValidationRule;
4645

47-
/**
48-
* @var RestResponse
49-
*/
50-
private $_response;
51-
5246
/**
5347
* QuoteValidator constructor.
5448
*
5549
* @param AllowedCountries|null $allowedCountryReader
5650
* @param OrderAmountValidationMessage|null $minimumAmountMessage
5751
* @param QuoteValidationRuleInterface|null $quoteValidationRule
58-
* @param RestResponse|null $response
5952
*/
6053
public function __construct(
6154
AllowedCountries $allowedCountryReader = null,
6255
OrderAmountValidationMessage $minimumAmountMessage = null,
63-
QuoteValidationRuleInterface $quoteValidationRule = null,
64-
RestResponse $response = null
56+
QuoteValidationRuleInterface $quoteValidationRule = null
6557
) {
6658
$this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance()
6759
->get(AllowedCountries::class);
6860
$this->minimumAmountMessage = $minimumAmountMessage ?: ObjectManager::getInstance()
6961
->get(OrderAmountValidationMessage::class);
7062
$this->quoteValidationRule = $quoteValidationRule ?: ObjectManager::getInstance()
7163
->get(QuoteValidationRuleInterface::class);
72-
$this->_response = $response ?: ObjectManager::getInstance()->get(RestResponse::class);
7364
}
7465

7566
/**
@@ -115,7 +106,6 @@ public function validateBeforeSubmit(QuoteEntity $quote)
115106
$defaultMessage .= ' %1';
116107
}
117108
if ($defaultMessage) {
118-
$this->_response->setHeader('errorRedirectAction', '#shipping');
119109
throw new ValidatorException(__($defaultMessage, implode(' ', $messages)));
120110
}
121111
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -46,12 +46,15 @@ public function validate(Quote $quote): array
4646
$billingAddress = $quote->getBillingAddress();
4747
$billingAddress->setStoreId($quote->getStoreId());
4848
$validationResult = $billingAddress->validate();
49-
if ($validationResult !== true) {
50-
$validationErrors = [__($this->generalMessage)];
51-
}
5249
if (is_array($validationResult)) {
5350
$validationErrors = array_merge($validationErrors, $validationResult);
5451
}
52+
if ($quote->getCustomerId() === null && $quote->getCustomerId() !== $quote->getOrigData('customer_id')) {
53+
return [$this->validationResultFactory->create(['errors' => $validationErrors])];
54+
}
55+
if ($validationResult !== true) {
56+
$validationErrors = array_merge([__($this->generalMessage)], $validationErrors);
57+
}
5558

5659
return [$this->validationResultFactory->create(['errors' => $validationErrors])];
5760
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Quote\Plugin\Webapi\Model;
9+
10+
use Magento\Framework\Validator\Exception as ValidatorException;
11+
use Magento\Framework\Webapi\Rest\Response as RestResponse;
12+
use Magento\Quote\Model\Quote;
13+
use Magento\Quote\Model\QuoteValidator;
14+
15+
class ErrorRedirectProcessor
16+
{
17+
/**
18+
* @param RestResponse $restResponse
19+
*/
20+
public function __construct(
21+
private readonly RestResponse $restResponse
22+
) {
23+
}
24+
25+
/**
26+
* Set errorRedirectAction in case of exception.
27+
*
28+
* @param QuoteValidator $subject
29+
* @param callable $proceed
30+
* @param Quote $quote
31+
*/
32+
public function aroundValidateBeforeSubmit(QuoteValidator $subject, callable $proceed, Quote $quote)
33+
{
34+
try {
35+
$result = $proceed($quote);
36+
} catch (ValidatorException $e) {
37+
$this->restResponse->setHeader('errorRedirectAction', '#shipping');
38+
throw $e;
39+
}
40+
41+
return $result;
42+
}
43+
}

0 commit comments

Comments
 (0)