Skip to content

Commit 0bc8f1f

Browse files
AC-10718::PHPUnit 10 upgrade Error: Call to undefined method PHPUnit 10 upgrade Error: Call to undefined method withConsecutive()() - Fix unit tests
1 parent 7ca0675 commit 0bc8f1f

File tree

35 files changed

+146
-73
lines changed

35 files changed

+146
-73
lines changed

app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function testCreate(): void
6868

6969
$this->objectManager->expects($this->exactly(2))->method('create')
7070
->willReturnCallback(function ($className) use ($factoryMock, $clientOptionsMock) {
71-
if ($className === 'engineFactoryClass') {
71+
if ($className == 'engineFactoryClass') {
7272
return $factoryMock;
73-
} elseif ($className === 'engineOptionClass') {
73+
} elseif ($className == 'engineOptionClass') {
7474
return $clientOptionsMock;
7575
}
7676
});

app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function testScheduleBulk(): void
154154
[$topicNames[1], [$operation]]
155155
];
156156
$index++;
157-
if($args === $expectedArgs[$index - 1]){
157+
if ($args === $expectedArgs[$index - 1]) {
158158
return null;
159159
}
160160
});

app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,20 @@ public function testPopulateAclFromCache(): void
117117
$aclMock->method('hasResource')->willReturn(true);
118118
$aclMock
119119
->method('allow')
120-
->willReturnCallback(function ($arg1, $arg2) {
121-
if ($arg2 === null) {
120+
->willReturnCallback(function ($arg1, $arg2, $arg3) {
121+
if ($arg1 == '1' && $arg2 === null && $arg3 === null) {
122122
return null;
123-
} elseif ($arg2 === 'Magento_Backend::all') {
123+
} elseif ($arg1 == '1' && $arg2 == 'Magento_Backend::all' && $arg3 === null) {
124124
return null;
125-
} elseif ($arg2 === '1') {
125+
} elseif ($arg1 == '2' && $arg2 == 1 && $arg3 === null) {
126126
return null;
127-
;
128127
}
129128
});
130129

131130
$aclMock
132131
->method('deny')
133132
->willReturnCallback(function ($arg1, $arg2, $arg3) {
134-
if ($arg1 === '3' && $arg2 == 1 && is_null($arg3)) {
133+
if ($arg1 == '3' && $arg2 == 1 && is_null($arg3)) {
135134
return null;
136135
}
137136
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testModifyMeta(string $shipmentTypePath, string $dataScope): voi
150150
->method('merge')
151151
->willReturnCallback(function ($arg1) use ($metaArgument) {
152152
if (is_null($arg1) || $arg1 == $metaArgument) {
153-
return [0 => '1'];
153+
return null;
154154
}
155155
});
156156
$this->bundlePanelModel->modifyMeta($sourceMeta);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function testSendPurgeRequest(array $hosts): void
117117

118118
/**
119119
* @return void
120+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
120121
*/
121122
public function testSendMultiPurgeRequest(): void
122123
{

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserEditObserverTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CheckUserEditObserverTest extends TestCase
3636
/** @var ActionFlag|MockObject */
3737
protected $actionFlagMock;
3838

39-
/* @var \Magento\Framework\Message\ManagerInterface|MockObject */
39+
/** @var \Magento\Framework\Message\ManagerInterface|MockObject */
4040
protected $messageManagerMock;
4141

4242
/** @var RedirectInterface|MockObject */
@@ -167,11 +167,10 @@ public function testExecute()
167167
->method('addErrorMessage')
168168
->willReturnCallback(function ($arg1) use ($message) {
169169
if ($arg1 == $message || $arg1 == (__('Incorrect CAPTCHA'))) {
170-
return '';
170+
return null;
171171
}
172172
});
173173

174-
175174
$this->actionFlagMock->expects($this->once())
176175
->method('set')
177176
->with('', Action::FLAG_NO_DISPATCH, true);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ public function testExecuteWithWebsitePrice(
259259
$index++;
260260
return $args === $expectedArgs[$index - 1] ? $returnValue : null;
261261
});
262-
263-
262+
264263
$this->tierPriceResource
265264
->expects($this->atLeastOnce())
266265
->method('loadPriceData')

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ public function testSave(): void
275275

276276
$originalValue1
277277
->method('getData')
278-
->willReturnCallback(function ($arg1, $arg2) {
278+
->willReturnCallback(function ($arg1) {
279279
if ($arg1 == 'option_type_id') {
280280
return 10;
281281
}
282282
});
283-
283+
284284
$originalValue1->expects($this->once())->method('setData')->with('is_delete', 1);
285285
$originalValue2->expects($this->once())->method('getData')->with('option_type_id')->willReturn(4);
286286
$originalValue3->expects($this->once())->method('getData')->with('option_type_id')->willReturn(5);

app/code/Magento/Catalog/Test/Unit/Plugin/Model/Attribute/Backend/AttributeValidationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function testAroundValidate(bool $shouldProceedRun, bool $defaultStoreUse
135135
->willReturn($attributeCode);
136136
$this->entityMock
137137
->method('getData')
138-
->willReturnCallback(function ($arg1, $arg2) use ($attributeCode) {
138+
->willReturnCallback(function ($arg1) use ($attributeCode) {
139139
if (empty($arg1)) {
140140
return [$attributeCode => null];
141141
} elseif ($arg1 == $attributeCode) {

app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,13 @@ public function testGetCustomOptionRange(): void
292292
$optionMaxValue = $option2MaxPrice + $option1MaxPrice;
293293
$this->priceCurrencyMock
294294
->method('convertAndRound')
295-
->willReturnCallback(fn($param) => match ([$param]) {
296-
[$option1MinPrice] => $convertMinValue,
297-
[$optionMaxValue] => $convertedMaxValue
295+
->willReturnCallback(function ($arg1)
296+
use ($option1MinPrice, $convertMinValue, $optionMaxValue, $convertedMaxValue) {
297+
if ($arg1 == $option1MinPrice) {
298+
return $convertMinValue;
299+
} elseif ($arg1 == $optionMaxValue) {
300+
return $convertedMaxValue;
301+
}
298302
});
299303
$this->assertEquals($option1MinPrice / 2, $this->object->getCustomOptionRange(true));
300304
$this->assertEquals($convertedMaxValue, $this->object->getCustomOptionRange(false));
@@ -398,9 +402,12 @@ public function testGetSelectedOptions(): void
398402
$this->product->setCustomOptions($customOptions);
399403
$this->product
400404
->method('getOptionById')
401-
->willReturnCallback(fn($param) => match ([$param]) {
402-
[$optionId1] => $optionMock,
403-
[$optionId2] => null
405+
->willReturnCallback(function ($arg) use ($optionId1, $optionMock) {
406+
if ($arg == $optionId1) {
407+
return $optionMock;
408+
} elseif ($arg == $optionId1) {
409+
return null;
410+
}
404411
});
405412
// Return from cache
406413
$result = $this->object->getSelectedOptions();

0 commit comments

Comments
 (0)