Skip to content

Commit e9c16d7

Browse files
authored
Merge pull request #7145 from magento-commerce/platform-health
[Platform Health] PHP 8 compatibility fixes
2 parents 177254d + d44a639 commit e9c16d7

File tree

162 files changed

+1281
-2052
lines changed

Some content is hidden

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

162 files changed

+1281
-2052
lines changed

app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function testRecreateWithExpression(
198198
->willReturn($this->selectMock);
199199
$withArgs = [];
200200

201-
foreach (array_keys($selectParts) as $key => $partName) {
201+
foreach (array_keys($selectParts) as $partName) {
202202
$withArgs[] = [$partName, $expectedParts[$partName]];
203203
}
204204
$this->selectMock

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ protected function setUp(): void
195195
$args = ['context' => $contextMock];
196196

197197
$testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
198-
$this->controller = $testHelper->getObject(
199-
Save::class,
200-
$args
201-
);
198+
$this->controller = $testHelper->getObject(Save::class, $args);
202199
}
203200

204201
/**

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,8 +1383,7 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
13831383
'getBundleOption',
13841384
'getBundleOptionsData'
13851385
]
1386-
)
1387-
->disableOriginalConstructor()
1386+
)->disableOriginalConstructor()
13881387
->getMock();
13891388
/* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Catalog\Model\Product\Option $option */
13901389
$option = $this->getMockBuilder(Option::class)
@@ -1405,8 +1404,7 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
14051404
'hasData',
14061405
'getData'
14071406
]
1408-
)
1409-
->addMethods(['getHasOptions', 'setCartQty', 'getSkipCheckRequiredOption'])
1407+
)->addMethods(['getHasOptions', 'setCartQty', 'getSkipCheckRequiredOption'])
14101408
->disableOriginalConstructor()
14111409
->getMock();
14121410
/** @var MockObject|Type $productType */
@@ -1419,7 +1417,6 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
14191417
->onlyMethods(['getItems'])
14201418
->disableOriginalConstructor()
14211419
->getMock();
1422-
14231420
$this->parentClass($group, $option, $buyRequest, $product);
14241421

14251422
$product->expects($this->any())
@@ -1444,7 +1441,6 @@ function ($key) use ($optionCollection) {
14441441
$resultValue = [0 => 5];
14451442
break;
14461443
}
1447-
14481444
return $resultValue;
14491445
}
14501446
);
@@ -1456,8 +1452,7 @@ function ($key) use ($optionCollection) {
14561452
$buyRequest->expects($this->once())
14571453
->method('getBundleOption')
14581454
->willReturn([3 => 5]);
1459-
$option
1460-
->method('getId')
1455+
$option->method('getId')
14611456
->willReturnOnConsecutiveCalls(3);
14621457
$option->expects($this->once())
14631458
->method('getRequired')

app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePanelTest.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,20 @@ public function testModifyMeta(string $shipmentTypePath, string $dataScope): voi
135135
->willReturn([]);
136136
$this->arrayManagerMock->method('set')
137137
->willReturn([]);
138+
139+
$metaArgument = [
140+
$shipmentTypePath . BundlePanel::META_CONFIG_PATH,
141+
[],
142+
[
143+
'dataScope' => $dataScope,
144+
'validation' => [
145+
'required-entry' => false
146+
]
147+
]
148+
];
138149
$this->arrayManagerMock
139150
->method('merge')
140-
->withConsecutive(
141-
[], [], [], [], [], [], [], [], [], [], [], [],
142-
[
143-
$shipmentTypePath . BundlePanel::META_CONFIG_PATH,
144-
[],
145-
[
146-
'dataScope' => $dataScope,
147-
'validation' => [
148-
'required-entry' => false
149-
]
150-
]
151-
]
152-
153-
);
151+
->withConsecutive([], [], [], [], [], [], [], [], [], [], [], [], $metaArgument);
154152
$this->bundlePanelModel->modifyMeta($sourceMeta);
155153
}
156154

app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ protected function setUp(): void
158158
'delete',
159159
'quoteInto',
160160
'fetchAssoc'
161-
])
161+
]
162+
)
162163
->disableOriginalConstructor()
163164
->getMock();
164165
$this->select = $this->createMock(Select::class);

app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public function testSendPurgeRequest(array $hosts): void
9191
$connectWithArgs = $writeWithArgs = [];
9292

9393
foreach ($uris as $uri) {
94-
$withArgs[] = [$uri->getHost(), $uri->getPort()];
9594
$writeWithArgs[] = ['PURGE', $uri, '1.1', ['X-Magento-Tags-Pattern' => 'tags', 'Host' => $uri->getHost()]];
9695
}
9796
$this->socketAdapterMock

app/code/Magento/Captcha/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"magento/module-sales": "*",
1414
"magento/module-store": "*",
1515
"magento/module-authorization": "*",
16-
"laminas/laminas-captcha": "^2.10",
17-
"laminas/laminas-db": "^2.8.2",
18-
"laminas/laminas-session": "^2.10"
16+
"laminas/laminas-captcha": "^2.11.0",
17+
"laminas/laminas-db": "^2.13.4",
18+
"laminas/laminas-session": "^2.12.0"
1919
},
2020
"type": "magento2-module",
2121
"license": [

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function execute()
168168
if (isset($categoryPostData['use_config']) && !empty($categoryPostData['use_config'])) {
169169
foreach ($categoryPostData['use_config'] as $attributeCode => $attributeValue) {
170170
if ($attributeValue) {
171-
$useConfig[] = $attributeValue;
171+
$useConfig[] = $attributeCode;
172172
$category->setData($attributeCode, null);
173173
}
174174
}

app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/SaveHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class SaveHandlerTest extends TestCase
3030
{
3131
/**
32-
* Magento\Framework\TestFramework\Unit\Helper\ObjectManager
32+
* @var ObjectManager
3333
*/
3434
private $objectManager;
3535

app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class CategoryTest extends TestCase
7676

7777
/**
7878
* @inheritDoc
79+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
7980
*/
8081
protected function setUp(): void
8182
{
@@ -105,8 +106,7 @@ protected function setUp(): void
105106
'getChildrenCategories',
106107
'getIsActive'
107108
]
108-
)
109-
->getMock();
109+
)->getMock();
110110

111111
$this->dataProvider
112112
->method('getCategory')
@@ -153,8 +153,7 @@ protected function setUp(): void
153153
'setValue',
154154
'setCount'
155155
]
156-
)
157-
->getMock();
156+
)->getMock();
158157
$filterItem->expects($this->any())
159158
->method($this->anything())->willReturnSelf();
160159
$this->filterItemFactory->expects($this->any())
@@ -192,12 +191,23 @@ protected function setUp(): void
192191
public function testApplyWithEmptyRequest($requestValue, $idValue): void
193192
{
194193
$requestField = 'test_request_var';
194+
$idField = 'id';
195195

196196
$this->target->setRequestVar($requestField);
197197

198198
$this->request
199199
->method('getParam')
200-
->with($requestField);
200+
->with($requestField)
201+
->willReturnCallback(
202+
function ($field) use ($requestField, $idField, $requestValue, $idValue) {
203+
switch ($field) {
204+
case $requestField:
205+
return $requestValue;
206+
case $idField:
207+
return $idValue;
208+
}
209+
}
210+
);
201211

202212
$result = $this->target->apply($this->request);
203213
$this->assertSame($this->target, $result);

0 commit comments

Comments
 (0)