Skip to content

Commit 45af4db

Browse files
authored
Merge pull request #5653 from magento-tsg/2.4-develop-php74-pr41
[TSG][PHP7.4] Fixes for 2.4 (pr41) (2.4-develop-php74)
2 parents 68e5a7b + c5fe646 commit 45af4db

File tree

36 files changed

+311
-116
lines changed

36 files changed

+311
-116
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontClearCompareActionGroup.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<waitForElementVisible selector="{{ModalConfirmationSection.OkButton}}" time="30" stepKey="waitForClearOk"/>
1919
<scrollTo selector="{{ModalConfirmationSection.OkButton}}" stepKey="scrollToClearOk"/>
2020
<click selector="{{ModalConfirmationSection.OkButton}}" stepKey="clickClearOk"/>
21-
<waitForElement selector="{{StorefrontMessagesSection.message('You cleared the comparison list.')}}" time="30" stepKey="AssertMessageCleared"/>
22-
<waitForElement selector="{{StorefrontComparisonSidebarSection.NoItemsMessage}}" time="30" stepKey="assertNoItems"/>
21+
<waitForElementVisible selector="{{StorefrontMessagesSection.message('You cleared the comparison list.')}}" time="30" stepKey="assertMessageCleared"/>
22+
<waitForElementVisible selector="{{StorefrontComparisonSidebarSection.NoItemsMessage}}" time="30" stepKey="assertNoItems"/>
2323
</actionGroup>
2424
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyComparedAtWebsiteLevelTest.xml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1010
<test name="StoreFrontRecentlyComparedAtWebsiteLevelTest">
1111
<annotations>
12+
<features value="Catalog"/>
1213
<stories value="Recently Compared Product"/>
1314
<title value="Recently Compared Product at website level"/>
1415
<description value="Recently Compared Products widget appears on a page immediately after adding product to compare"/>
15-
<useCaseId value="MC-32763"/>
16-
<testCaseId value="MC-33099"/>
1716
<severity value="MAJOR"/>
17+
<testCaseId value="MC-33099"/>
18+
<useCaseId value="MC-32763"/>
1819
<group value="catalog"/>
1920
<group value="widget"/>
2021
</annotations>
2122
<before>
23+
<!-- Set Stores > Configurations > Catalog > Recently Viewed/Compared Products > Show for Current = Website -->
24+
<magentoCLI command="config:set {{RecentlyViewedProductScopeWebsite.path}} {{RecentlyViewedProductScopeWebsite.value}}" stepKey="setRecentlyViewedComparedProductsScopeToWebsite"/>
2225
<!--Create Simple Products and Category -->
2326
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
2427
<createData entity="SimpleProduct" stepKey="createSimpleProductToCompareFirst">
@@ -40,67 +43,63 @@
4043
<actionGroup ref="AdminCreateRecentlyProductsWidgetActionGroup" stepKey="createRecentlyComparedProductsWidget">
4144
<argument name="widget" value="RecentlyComparedProductsWidget"/>
4245
</actionGroup>
43-
<!-- Set Stores > Configurations > Catalog > Recently Viewed/Compared Products > Show for Current = Website -->
44-
<magentoCLI command="config:set {{RecentlyViewedProductScopeWebsite.path}} {{RecentlyViewedProductScopeWebsite.value}}" stepKey="RecentlyViewedProductScopeWebsiteGroup"/>
4546
</before>
4647
<after>
47-
<!-- Customer Logout -->
48-
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutFromCustomer"/>
49-
<!-- Delete product widget -->
50-
<actionGroup ref="AdminDeleteWidgetActionGroup" stepKey="deleteRecentlyComparedProductsWidget">
51-
<argument name="widget" value="RecentlyComparedProductsWidget"/>
52-
</actionGroup>
53-
<!-- Logout Admin -->
54-
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
5548
<!-- Reset Stores > Configurations > Catalog > Recently Viewed/Compared Products > Show for Current = Website-->
56-
<magentoCLI command="config:set {{RecentlyViewedProductScopeWebsite.path}} {{RecentlyViewedProductScopeWebsite.value}}" stepKey="RecentlyViewedProductScopeWebsite"/>
49+
<magentoCLI command="config:set {{RecentlyViewedProductScopeWebsite.path}} {{RecentlyViewedProductScopeWebsite.value}}" stepKey="setRecentlyViewedComparedProductsScopeToDefault"/>
5750
<!-- Delete Products and Category -->
5851
<deleteData createDataKey="createSimpleProductToCompareFirst" stepKey="deleteSimpleProductToCompareFirst"/>
5952
<deleteData createDataKey="createSimpleProductToCompareSecond" stepKey="deleteSimpleProductToCompareSecond"/>
6053
<deleteData createDataKey="createSimpleProductNotVisibleFirst" stepKey="deleteSimpleProductNotVisibleFirst"/>
6154
<deleteData createDataKey="createSimpleProductNotVisibleSecond" stepKey="deleteSimpleProductNotVisibleSecond"/>
6255
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
56+
<!-- Customer Logout -->
57+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutFromCustomer"/>
6358
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
59+
<!-- Delete product widget -->
60+
<actionGroup ref="AdminDeleteWidgetActionGroup" stepKey="deleteRecentlyComparedProductsWidget">
61+
<argument name="widget" value="RecentlyComparedProductsWidget"/>
62+
</actionGroup>
63+
<!-- Logout Admin -->
64+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
6465
</after>
6566
<!--Login to storefront from customer-->
6667
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCustomer">
67-
<argument name="Customer" value="$$createCustomer$$"/>
68+
<argument name="Customer" value="$createCustomer$"/>
6869
</actionGroup>
69-
<see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessage"/>
70-
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="openCategoryPageAfterAddedProductToCart"/>
70+
<see userInput="Welcome, $createCustomer.firstname$ $createCustomer.lastname$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessage"/>
71+
<amOnPage url="{{StorefrontCategoryPage.url($createCategory.custom_attributes[url_key]$)}}" stepKey="openCategoryPage"/>
7172
<!--Add to compare Simple Product and Simple Product 2-->
7273
<actionGroup ref="StorefrontAddCategoryProductToCompareActionGroup" stepKey="addSimpleProduct1ToCompare" >
73-
<argument name="productVar" value="$$createSimpleProductToCompareFirst$$"/>
74+
<argument name="productVar" value="$createSimpleProductToCompareFirst$"/>
7475
</actionGroup>
7576
<actionGroup ref="StorefrontAddCategoryProductToCompareActionGroup" stepKey="addSimpleProduct2ToCompare" >
76-
<argument name="productVar" value="$$createSimpleProductToCompareSecond$$"/>
77+
<argument name="productVar" value="$createSimpleProductToCompareSecond$"/>
7778
</actionGroup>
7879
<!--The Compare Products widget displays Simple Product 1 and Simple Product 2-->
7980
<actionGroup ref="StorefrontCheckCompareSidebarProductActionGroup" stepKey="checkSimpleProduct1InCompareSidebar">
80-
<argument name="productVar" value="$$createSimpleProductToCompareFirst$$"/>
81+
<argument name="productVar" value="$createSimpleProductToCompareFirst$"/>
8182
</actionGroup>
8283
<actionGroup ref="StorefrontCheckCompareSidebarProductActionGroup" stepKey="checkSimpleProduct2InCompareSidebar">
83-
<argument name="productVar" value="$$createSimpleProductToCompareSecond$$"/>
84+
<argument name="productVar" value="$createSimpleProductToCompareSecond$"/>
8485
</actionGroup>
8586

8687
<!--Click Clear all in the Compare Products widget-->
8788
<actionGroup ref="StorefrontClearCompareActionGroup" stepKey="clearCompareList"/>
8889
<!--The Recently Compared widget displays Simple Product 1 and Simple Product 2-->
89-
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="openCategoryPageToCheckProductsInRecentlyComparedSidebar"/>
90+
<waitForPageLoad stepKey="waitForRecentlyComparedWidgetLoad"/>
9091
<actionGroup ref="StorefrontAssertProductInRecentlyComparedWidgetActionGroup" stepKey="checkSimpleProduct1ExistInRecentlyComparedWidget">
91-
<argument name="product" value="$$createSimpleProductToCompareFirst$$"/>
92+
<argument name="product" value="$createSimpleProductToCompareFirst$"/>
9293
</actionGroup>
9394
<actionGroup ref="StorefrontAssertProductInRecentlyComparedWidgetActionGroup" stepKey="checkSimpleProduct2ExistInRecentlyComparedWidget">
94-
<argument name="product" value="$$createSimpleProductToCompareSecond$$"/>
95+
<argument name="product" value="$createSimpleProductToCompareSecond$"/>
9596
</actionGroup>
9697
<!--The Recently Compared widget not displays Simple Product 3 and Simple Product 4-->
9798
<actionGroup ref="StorefrontAssertNotExistProductInRecentlyComparedWidgetActionGroup" stepKey="checkSimpleProduct3NotExistInRecentlyComparedWidget">
98-
<argument name="product" value="$$createSimpleProductNotVisibleFirst$$"/>
99+
<argument name="product" value="$createSimpleProductNotVisibleFirst$"/>
99100
</actionGroup>
100101
<actionGroup ref="StorefrontAssertNotExistProductInRecentlyComparedWidgetActionGroup" stepKey="checkSimpleProduct4NotExistInRecentlyComparedWidget">
101-
<argument name="product" value="$$createSimpleProductNotVisibleSecond$$"/>
102+
<argument name="product" value="$createSimpleProductNotVisibleSecond$"/>
102103
</actionGroup>
103-
<amOnPage url="customer/account/logout/" stepKey="logoutCustomer"/>
104-
<waitForPageLoad time="30" stepKey="waitForPageLoad2"/>
105104
</test>
106105
</tests>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminCatalogPriceRuleDeleteAllActionGroup">
11+
<annotations>
12+
<description>Open Catalog Price Rule grid and delete all rules one by one. Need to avoid interference with other tests that test catalog price rules.</description>
13+
</annotations>
14+
15+
<amOnPage url="{{AdminCatalogPriceRuleGridPage.url}}" stepKey="goToAdminCatalogPriceRuleGridPage"/>
16+
<!-- It sometimes is loading too long for default 10s -->
17+
<waitForPageLoad time="60" stepKey="waitForPageFullyLoaded"/>
18+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/>
19+
<helper class="\Magento\CatalogRule\Test\Mftf\Helper\CatalogPriceRuleHelper" method="deleteAllCatalogPriceRules" stepKey="deleteAllCatalogPriceRulesOneByOne">
20+
<argument name="firstNotEmptyRow">{{AdminDataGridTableSection.firstNotEmptyRow}}</argument>
21+
<argument name="modalAcceptButton">{{AdminConfirmationModalSection.ok}}</argument>
22+
<argument name="deleteButton">{{AdminMainActionsSection.delete}}</argument>
23+
<argument name="successMessageContainer">{{AdminMessagesSection.success}}</argument>
24+
<argument name="successMessage">You deleted the rule.</argument>
25+
</helper>
26+
<waitForElementVisible selector="{{AdminDataGridTableSection.dataGridEmpty}}" stepKey="waitDataGridEmptyMessageAppears"/>
27+
<see selector="{{AdminDataGridTableSection.dataGridEmpty}}" userInput="We couldn't find any records." stepKey="assertDataGridEmptyMessage"/>
28+
</actionGroup>
29+
</actionGroups>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Test\Mftf\Helper;
9+
10+
use Facebook\WebDriver\Remote\RemoteWebDriver as FacebookWebDriver;
11+
use Facebook\WebDriver\WebDriverBy;
12+
use Magento\FunctionalTestingFramework\Helper\Helper;
13+
use Magento\FunctionalTestingFramework\Module\MagentoWebDriver;
14+
15+
/**
16+
* Class for MFTF helpers for CatalogRule module.
17+
*/
18+
class CatalogPriceRuleHelper extends Helper
19+
{
20+
/**
21+
* Delete all Catalog Price Rules obe by one.
22+
*
23+
* @param string $emptyRow
24+
* @param string $modalAceptButton
25+
* @param string $deleteButton
26+
* @param string $successMessageContainer
27+
* @param string $successMessage
28+
*
29+
* @return void
30+
*/
31+
public function deleteAllCatalogPriceRules(
32+
string $firstNotEmptyRow,
33+
string $modalAcceptButton,
34+
string $deleteButton,
35+
string $successMessageContainer,
36+
string $successMessage
37+
): void {
38+
try {
39+
/** @var MagentoWebDriver $webDriver */
40+
$magentoWebDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
41+
/** @var FacebookWebDriver $webDriver */
42+
$webDriver = $magentoWebDriver->webDriver;
43+
$rows = $webDriver->findElements(WebDriverBy::cssSelector($firstNotEmptyRow));
44+
while (!empty($rows)) {
45+
$rows[0]->click();
46+
$magentoWebDriver->waitForPageLoad(30);
47+
$magentoWebDriver->click($deleteButton);
48+
$magentoWebDriver->waitForPageLoad(30);
49+
$magentoWebDriver->waitForElementVisible($modalAcceptButton, 10);
50+
$magentoWebDriver->waitForPageLoad(60);
51+
$magentoWebDriver->click($modalAcceptButton);
52+
$magentoWebDriver->waitForPageLoad(60);
53+
$magentoWebDriver->waitForLoadingMaskToDisappear();
54+
$magentoWebDriver->waitForElementVisible($successMessageContainer, 10);
55+
$magentoWebDriver->see($successMessage, $successMessageContainer);
56+
$rows = $webDriver->findElements(WebDriverBy::cssSelector($firstNotEmptyRow));
57+
}
58+
} catch (\Exception $e) {
59+
$this->fail($e->getMessage());
60+
}
61+
}
62+
}

app/code/Magento/Customer/Model/Customer/DataProviderWithDefaultAddresses.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private function prepareDefaultAddress($address): array
165165
if (isset($addressData['street']) && !\is_array($address['street'])) {
166166
$addressData['street'] = explode("\n", $addressData['street']);
167167
}
168-
$addressData['country'] = $this->countryFactory->create()
169-
->loadByCode($addressData['country_id'])->getName();
168+
$countryId = $addressData['country_id'] ?? null;
169+
$addressData['country'] = $this->countryFactory->create()->loadByCode($countryId)->getName();
170170
}
171171

172172
return $addressData;

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ public function getLinkField()
766766
if (!$this->linkIdField) {
767767
$indexList = $this->getConnection()->getIndexList($this->getEntityTable());
768768
$pkName = $this->getConnection()->getPrimaryKeyName($this->getEntityTable());
769-
$this->linkIdField = $indexList[$pkName]['COLUMNS_LIST'][0];
769+
$this->linkIdField = $indexList[$pkName]['COLUMNS_LIST'][0] ?? null;
770770
if (!$this->linkIdField) {
771771
$this->linkIdField = $this->getEntityIdField();
772772
}

app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/Grouped/LinksTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,25 @@ public function testSaveLinksDataWithProductsAttrs($linksData)
108108
$linksData['attr_product_ids'] = [12 => true, 16 => true];
109109
$linksData['position'] = [4 => 6];
110110
$linksData['qty'] = [9 => 3];
111+
$attributes = [
112+
['id' => 1, 'code' => 'position', 'type' => 'int'],
113+
['id' => 2, 'code' => 'qty', 'type' => 'decimal'],
114+
];
111115
$this->processBehaviorGetter('append');
112116
$select = $this->createMock(Select::class);
113-
$this->connection->expects($this->any())->method('select')->will($this->returnValue($select));
114-
$select->expects($this->any())->method('from')->willReturnSelf();
115-
$select->expects($this->any())->method('where')->willReturnSelf();
116-
$this->connection->expects($this->once())->method('fetchAll')->with($select)->will($this->returnValue([]));
117+
$this->connection->expects($this->exactly(2))->method('select')->will($this->returnValue($select));
118+
$select->expects($this->exactly(2))->method('from')->willReturnSelf();
119+
$select->expects($this->exactly(2))->method('where')->willReturnSelf();
120+
$this->connection->expects($this->once())->method('fetchAll')
121+
->with($select)->will($this->returnValue($attributes));
117122
$this->connection->expects($this->once())->method('fetchPairs')->with($select)->will(
118123
$this->returnValue([])
119124
);
120125
$this->connection->expects($this->exactly(4))->method('insertOnDuplicate');
126+
$this->link->expects($this->exactly(2))->method('getAttributeTypeTable')->willReturn(
127+
'table_name'
128+
);
129+
121130
$this->links->saveLinksData($linksData);
122131
}
123132

app/code/Magento/ImportExport/Helper/Report.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ public function getReportAbsolutePath($fileName)
111111
* Retrieve report file size
112112
*
113113
* @param string $filename
114-
* @return int|mixed
114+
* @return int|null
115115
*/
116116
public function getReportSize($filename)
117117
{
118-
return $this->varDirectory->stat($this->getFilePath($filename))['size'];
118+
$statResult = $this->varDirectory->stat($this->getFilePath($filename));
119+
120+
return $statResult['size'] ?? null;
119121
}
120122

121123
/**

app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function setUp(): void
9393
$this->varDirectory->expects($this->any())->method('getRelativePath')->willReturn('path');
9494
$this->varDirectory->expects($this->any())->method('readFile')->willReturn('contents');
9595
$this->varDirectory->expects($this->any())->method('isFile')->willReturn(true);
96-
$this->varDirectory->expects($this->any())->method('stat')->willReturn(100);
96+
$this->varDirectory->expects($this->any())->method('stat')->willReturn(false);
9797
$this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->varDirectory);
9898
$this->objectManagerHelper = new ObjectManagerHelper($this);
9999
$this->report = $this->objectManagerHelper->getObject(

app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8383

8484
$startTime = microtime(true);
8585
$indexerConfig = $this->getConfig()->getIndexer($indexer->getId());
86-
$sharedIndex = $indexerConfig['shared_index'];
86+
$sharedIndex = $indexerConfig['shared_index'] ?? null;
8787

8888
// Skip indexers having shared index that was already complete
8989
if (!in_array($sharedIndex, $this->sharedIndexesComplete)) {

0 commit comments

Comments
 (0)