Skip to content

Commit 1675c5b

Browse files
authored
Merge branch '2.4-develop' into upgrade-phpstan-to-first-stable-version
2 parents e7c8809 + f95efe4 commit 1675c5b

File tree

51 files changed

+4588
-1991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4588
-1991
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
104104
$this->addDefaultSortOrder($searchCriteria, $args, $isSearch);
105105
}
106106

107-
$this->addEntityIdSort($searchCriteria, $isSearch);
107+
$this->addEntityIdSort($searchCriteria, $args);
108108
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));
109109

110110
$searchCriteria->setCurrentPage($args['currentPage']);
@@ -137,17 +137,15 @@ private function addVisibilityFilter(SearchCriteriaInterface $searchCriteria, bo
137137
* Add sort by Entity ID
138138
*
139139
* @param SearchCriteriaInterface $searchCriteria
140-
* @param bool $isSearch
140+
* @param array $args
141141
*/
142-
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, bool $isSearch): void
142+
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, array $args): void
143143
{
144-
if ($isSearch) {
145-
return;
146-
}
144+
$sortOrder = !empty($args['sort']) ? reset($args['sort']) : SortOrder::SORT_DESC;
147145
$sortOrderArray = $searchCriteria->getSortOrders();
148146
$sortOrderArray[] = $this->sortOrderBuilder
149147
->setField('_id')
150-
->setDirection(SortOrder::SORT_DESC)
148+
->setDirection($sortOrder)
151149
->create();
152150
$searchCriteria->setSortOrders($sortOrderArray);
153151
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontAddressDeletedStreetAddressRemainsEmptyAfterRefreshTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<stories value="Guest checkout"/>
15+
<title value="Address Street Field Remain Empty when deleted even After Browser Refresh"/>
16+
<description value="Address Street Field Remain Empty when deleted even After Browser Refresh"/>
17+
<severity value="MINOR"/>
18+
<testCaseId value="MC-43255"/>
19+
<group value="checkout"/>
20+
</annotations>
21+
<before>
22+
<createData entity="simpleProductWithoutCategory" stepKey="createSimpleProduct"/>
23+
</before>
24+
<after>
25+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
26+
</after>
27+
<!--Step 1 Add simple product to the cart -->
28+
<actionGroup ref="StorefrontAddSimpleProductToShoppingCartActionGroup" stepKey="addProductToCart">
29+
<argument name="product" value="$createSimpleProduct$"/>
30+
</actionGroup>
31+
32+
<!--Step 2 Proceed to Checkout and be on Shipping page -->
33+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckout"/>
34+
35+
<!--Step 3 Select Country as United Kingdom, select address street and Refresh the page-->
36+
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{UK_Address.country_id}}" stepKey="selectUnitedKingdomCounty"/>
37+
<waitForPageLoad stepKey="waitFormToReloadAfterSelectCountry"/>
38+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{UK_Address.street[0]}}" stepKey="enterAddressStreet"/>
39+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPageAfterAddressIsAdded"/>
40+
<!-- Step 4 Assert Entered details should be retained and delete an address -->
41+
<seeInField selector="{{CheckoutShippingSection.street}}" userInput="{{UK_Address.street[0]}}" stepKey="seeAddressStreetUnitedKingdom"/>
42+
<clearField selector="{{CheckoutShippingSection.street}}" stepKey="deleteAddressStreet"/>
43+
<!-- Assert Entered details should be retained and State/Province field should be displayed as an optional field (without * ) -->
44+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPageAfterAddressIsDeleted"/>
45+
<seeInField selector="{{CheckoutShippingSection.street}}" userInput="" stepKey="seeAddressStreetIsempty"/>
46+
</test>
47+
</tests>

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,36 @@ define([
120120
$.extend(true, {}, checkoutProvider.get('shippingAddress'), shippingAddressData)
121121
);
122122
}
123-
checkoutProvider.on('shippingAddress', function (shippingAddrsData) {
124-
if (shippingAddrsData.street && !_.isEmpty(shippingAddrsData.street[0])) {
123+
checkoutProvider.on('shippingAddress', function (shippingAddrsData, changes) {
124+
var isStreetAddressDeleted, isStreetAddressNotEmpty;
125+
126+
/**
127+
* In last modifying operation street address was deleted.
128+
* @return {Boolean}
129+
*/
130+
isStreetAddressDeleted = function () {
131+
var change;
132+
133+
if (!changes || changes.length === 0) {
134+
return false;
135+
}
136+
137+
change = changes.pop();
138+
139+
if (_.isUndefined(change.value) || _.isUndefined(change.oldValue)) {
140+
return false;
141+
}
142+
143+
if (!change.path.startsWith('shippingAddress.street')) {
144+
return false;
145+
}
146+
147+
return change.value.length === 0 && change.oldValue.length > 0;
148+
};
149+
150+
isStreetAddressNotEmpty = shippingAddrsData.street && !_.isEmpty(shippingAddrsData.street[0]);
151+
152+
if (isStreetAddressNotEmpty || isStreetAddressDeleted()) {
125153
checkoutData.setShippingAddressFromData(shippingAddrsData);
126154
}
127155
});

app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/AttributesTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,13 @@ public function testPrepareDataSource()
109109
$name = 'some_name';
110110
$initialData = [
111111
'data' => [
112+
'totalRecords' => 4,
112113
'items' => [
113-
['attribute1_1_code' => 'attribute1_1_option2'],
114-
['attribute2_1_code' => 'attribute2_1_option3'],
115-
['attribute3_1_code' => 'attribute3_1_option3', 'attribute3_2_code' => 'attribute3_2_option1']
114+
['attribute1_1_code' => 'attribute1_1_option2', 'required_options' => '0'],
115+
['attribute2_1_code' => 'attribute2_1_option3', 'required_options' => '0'],
116+
['attribute3_1_code' => 'attribute3_1_option3', 'attribute3_2_code' => 'attribute3_2_option1',
117+
'required_options' => '0'],
118+
['attribute4_1_code' => 'attribute4_1_option1', 'required_options' => '1']
116119
]
117120
]
118121
];
@@ -158,18 +161,22 @@ public function testPrepareDataSource()
158161
];
159162
$resultData = [
160163
'data' => [
164+
'totalRecords' => 3,
161165
'items' => [
162166
[
163167
'attribute1_1_code' => 'attribute1_1_option2',
168+
'required_options' => '0',
164169
$name => 'attribute1_1_label: attribute1_1_option2_label'
165170
],
166171
[
167172
'attribute2_1_code' => 'attribute2_1_option3',
173+
'required_options' => '0',
168174
$name => ''
169175
],
170176
[
171177
'attribute3_1_code' => 'attribute3_1_option3',
172178
'attribute3_2_code' => 'attribute3_2_option1',
179+
'required_options' => '0',
173180
$name => 'attribute3_1_label: attribute3_1_option3_label,'
174181
. ' attribute3_2_label: attribute3_2_option1_label'
175182
]
@@ -187,7 +194,9 @@ public function testPrepareDataSource()
187194
->method('getItems')
188195
->willReturn($attributes);
189196

190-
$this->assertSame($resultData, $this->attributesColumn->prepareDataSource($initialData));
197+
$actualResultItems = $this->attributesColumn->prepareDataSource($initialData);
198+
$this->assertSame($resultData['data']['items'], $actualResultItems['data']['items']);
199+
$this->assertSame($resultData['data']['totalRecords'], count($actualResultItems['data']['items']));
191200
}
192201

193202
/**

app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Attributes.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ public function prepareDataSource(array $dataSource)
5959
if (isset($dataSource['data']['items'])) {
6060
$attributes = $this->getAttributes();
6161
$fieldName = $this->getData('name');
62-
foreach ($dataSource['data']['items'] as & $item) {
62+
foreach ($dataSource['data']['items'] as $key => & $item) {
6363
$attrStrings = [];
6464
foreach ($attributes as $attributeCode => $attribute) {
65+
if ($item['required_options'] === "1") {
66+
unset($dataSource['data']['items'][$key]);
67+
$dataSource['data']['totalRecords']--;
68+
continue;
69+
}
70+
6571
if (isset($item[$attributeCode]) && isset($attribute['options'][$item[$attributeCode]])) {
6672
$attrStrings[] = $attribute['label'] . ': ' . $attribute['options'][$item[$attributeCode]];
6773
}
@@ -71,6 +77,7 @@ public function prepareDataSource(array $dataSource)
7177
}
7278
}
7379

80+
$dataSource['data']['items'] = array_values($dataSource['data']['items']);
7481
return $dataSource;
7582
}
7683

app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\State;
1515
use Magento\Framework\Console\Cli;
1616
use Magento\Framework\Event\ObserverInterface;
17+
use Magento\Framework\Exception\CronException;
1718
use Magento\Framework\Profiler\Driver\Standard\Stat;
1819
use Magento\Framework\Profiler\Driver\Standard\StatFactory;
1920
use Magento\Cron\Model\DeadlockRetrierInterface;
@@ -822,10 +823,16 @@ private function processPendingJobs(string $groupId, array $jobsRoot, int $curre
822823
continue;
823824
}
824825

825-
$this->tryRunJob($scheduledTime, $currentTime, $jobConfig, $schedule, $groupId);
826-
827-
if ($schedule->getStatus() === Schedule::STATUS_SUCCESS) {
828-
$processedJobs[$schedule->getJobCode()] = true;
826+
try {
827+
$this->tryRunJob($scheduledTime, $currentTime, $jobConfig, $schedule, $groupId);
828+
if ($schedule->getStatus() === Schedule::STATUS_SUCCESS) {
829+
$processedJobs[$schedule->getJobCode()] = true;
830+
}
831+
} catch (CronException $e) {
832+
$this->logger->warning($e->getMessage());
833+
continue;
834+
} catch (\Exception $e) {
835+
$this->processError($schedule, $e);
829836
}
830837

831838
$this->retrier->execute(
@@ -845,6 +852,7 @@ function () use ($schedule) {
845852
* @param string[] $jobConfig
846853
* @param Schedule $schedule
847854
* @param string $groupId
855+
* @throws CronException
848856
*/
849857
private function tryRunJob($scheduledTime, $currentTime, $jobConfig, $schedule, $groupId)
850858
{
@@ -858,10 +866,10 @@ private function tryRunJob($scheduledTime, $currentTime, $jobConfig, $schedule,
858866
$this->_runJob($scheduledTime, $currentTime, $jobConfig, $schedule, $groupId);
859867
break;
860868
}
861-
$this->logger->warning("Could not acquire lock for cron job: {$schedule->getJobCode()}");
869+
if ($retries === 1) {
870+
throw new CronException(__('Could not acquire lock for cron job: %1', $schedule->getJobCode()));
871+
}
862872
}
863-
} catch (\Exception $e) {
864-
$this->processError($schedule, $e);
865873
} finally {
866874
$this->lockManager->unlock($lockName);
867875
}

app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,15 @@ public function testDispatchCanNotLock(): void
307307
$schedule->expects($this->atLeastOnce())->method('getScheduledAt')->willReturn($dateScheduledAt);
308308
$schedule->expects($this->exactly(5))->method('tryLockJob')->willReturn(false);
309309
$schedule->expects($this->never())->method('setFinishedAt');
310-
$schedule->expects($this->once())->method('getResource')->willReturn($this->scheduleResourceMock);
310+
$schedule->expects($this->never())->method('getResource')->willReturn($this->scheduleResourceMock);
311311

312312
$connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
313313

314-
$this->scheduleResourceMock->expects($this->once())
314+
$this->scheduleResourceMock->expects($this->never())
315315
->method('getConnection')
316316
->willReturn($connectionMock);
317317

318-
$this->retrierMock->expects($this->once())
318+
$this->retrierMock->expects($this->never())
319319
->method('execute')
320320
->willReturnCallback(
321321
function ($callback) {
@@ -341,7 +341,9 @@ function ($callback) {
341341
$this->scheduleFactoryMock->expects($this->atLeastOnce())
342342
->method('create')
343343
->willReturn($scheduleMock);
344-
344+
$this->loggerMock->expects($this->once())
345+
->method('warning')
346+
->with('Could not acquire lock for cron job: test_job1');
345347
$this->cronQueueObserver->execute($this->observerMock);
346348
}
347349

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,6 @@ public function execute()
444444
*/
445445
private function updateSubscriptions(CustomerInterface $customer): void
446446
{
447-
if (!$this->_authorization->isAllowed(null)) {
448-
return;
449-
}
450-
451447
$subscriptionStatus = (array)$this->getRequest()->getParam('subscription_status');
452448
$subscriptionStore = (array)$this->getRequest()->getParam('subscription_store');
453449
if (empty($subscriptionStatus)) {

app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCustomGroupTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
</annotations>
2020

2121
<before>
22+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
23+
<argument name="indices" value="customer_grid"/>
24+
</actionGroup>
2225
<createData entity="CustomCustomerGroup" stepKey="customerGroup" />
2326
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
2427
</before>

app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithoutAddressTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
</annotations>
2020

2121
<before>
22+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindexAfterTest">
23+
<argument name="indices" value="customer_grid"/>
24+
</actionGroup>
2225
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/>
2326
</before>
2427
<after>

app/code/Magento/Customer/Test/Mftf/Test/AdminSearchCustomerAddressByKeywordTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
<before>
2222
<createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/>
23-
<comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/>
23+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
24+
<argument name="indices" value="customer_grid"/>
25+
</actionGroup>
2426
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
2527
</before>
2628
<after>

app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminUpdateCustomerInfoFromDefaultToNonDefaultTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
</annotations>
2121
<before>
2222
<createData stepKey="customer" entity="Simple_Customer_Without_Address"/>
23-
<comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/>
23+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
24+
<argument name="indices" value="customer_grid"/>
25+
</actionGroup>
2426
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
2527
</before>
2628
<after>

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,6 @@ public function testExecuteWithExistentCustomer()
495495
->with($customerMock, $customerEmail)
496496
->willReturnSelf();
497497

498-
$this->authorizationMock->expects($this->once())
499-
->method('isAllowed')
500-
->with(null)
501-
->willReturn(true);
502-
503498
$this->subscriptionManager->expects($this->once())
504499
->method($subscriptionStatus ? 'subscribeCustomer' : 'unsubscribeCustomer')
505500
->with($customerId, $subscriptionStore);
@@ -670,10 +665,6 @@ public function testExecuteWithNewCustomer()
670665
->method('createAccount')
671666
->with($customerMock, null, '')
672667
->willReturn($customerMock);
673-
$this->authorizationMock->expects($this->once())
674-
->method('isAllowed')
675-
->with(null)
676-
->willReturn(true);
677668
$this->subscriptionManager->expects($this->once())
678669
->method($subscriptionStatus ? 'subscribeCustomer' : 'unsubscribeCustomer')
679670
->with($customerId, $subscriptionStore);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertEmailTemplateIndexActionGroup">
12+
<arguments>
13+
<argument name="expectedContent" type="string" defaultValue="{{EmailTemplate.templateName}}"/>
14+
</arguments>
15+
16+
<see userInput="{{expectedContent}}" selector="{{AdminEmailTemplateIndexSection.templateRowByName(EmailTemplate.templateName)}}" stepKey="checkGridIsPresent"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="FindEmailTemplateActionGroup">
12+
<arguments>
13+
<argument name="template" defaultValue="EmailTemplate"/>
14+
</arguments>
15+
16+
<amOnPage url="{{AdminEmailTemplateIndexPage.url}}" stepKey="navigateEmailTemplatePage" />
17+
<click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clearFilters"/>
18+
<fillField selector="{{AdminEmailTemplateIndexSection.searchTemplateField}}" userInput="{{template.templateName}}" stepKey="findCreatedTemplate"/>
19+
<click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickSearch"/>
20+
<waitForElementVisible selector="{{AdminEmailTemplateIndexSection.templateRowByName(template.templateName)}}" stepKey="waitForTemplatesAppeared"/>
21+
</actionGroup>
22+
</actionGroups>

0 commit comments

Comments
 (0)