Skip to content

Commit e6d5be7

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 0bc8f1f commit e6d5be7

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static function ($value) {
9494
* Test populating acl rule from cache.
9595
*
9696
* @return void
97+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9798
*/
9899
public function testPopulateAclFromCache(): void
99100
{

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ImageTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ public function testGetCountAllProductImages(int $imagesCount): void
118118
$selectMock = $this->getVisibleImagesSelectMock();
119119
$selectMock->expects($this->exactly(2))
120120
->method('reset')
121-
->willReturnCallback(fn($param) => match ([$param]) {
122-
['columns'] =>$selectMock,
123-
['distinct'] => $selectMock
124-
});
121+
->withConsecutive(
122+
['columns'],
123+
['distinct']
124+
)->willReturnSelf();
125125
$selectMock->expects($this->once())
126126
->method('columns')
127127
->with(new \Zend_Db_Expr('count(distinct value)'))
@@ -158,10 +158,10 @@ public function testGetCountUsedProductImages(int $imagesCount): void
158158
$selectMock = $this->getUsedImagesSelectMock();
159159
$selectMock->expects($this->exactly(2))
160160
->method('reset')
161-
->willReturnCallback(fn($param) => match ([$param]) {
162-
['columns'] =>$selectMock,
163-
['distinct'] => $selectMock
164-
});
161+
->withConsecutive(
162+
['columns'],
163+
['distinct']
164+
)->willReturnSelf();
165165
$selectMock->expects($this->once())
166166
->method('columns')
167167
->with(new \Zend_Db_Expr('count(distinct value)'))
@@ -338,7 +338,7 @@ protected function getBatchIteratorCallback(
338338
* Data Provider
339339
* @return array
340340
*/
341-
public static function dataProvider(): array
341+
public function dataProvider(): array
342342
{
343343
return [
344344
[300, 300],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ public function testGetSelectedOptions(): void
402402
$this->product->setCustomOptions($customOptions);
403403
$this->product
404404
->method('getOptionById')
405-
->willReturnCallback(function ($arg) use ($optionId1, $optionMock) {
405+
->willReturnCallback(function ($arg) use ($optionId1, $optionId2, $optionMock) {
406406
if ($arg == $optionId1) {
407407
return $optionMock;
408-
} elseif ($arg == $optionId1) {
408+
} elseif ($arg == $optionId2) {
409409
return null;
410410
}
411411
});

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,7 @@ protected function setPropertyValue(&$object, $property, $value)
12671267
*
12681268
* @return void
12691269
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1270+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
12701271
*/
12711272
public function testSubmitForCustomer(): void
12721273
{
@@ -1397,6 +1398,7 @@ private function createPartialMockForAbstractClass(string $className, array $met
13971398
* @return void
13981399
*
13991400
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1401+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
14001402
*/
14011403
public function testSubmitWithLockException(): void
14021404
{

app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function testExecute(): void
213213
->willReturnCallback(function ($arg1, $arg2) use ($orderId, $invoiceData) {
214214
if ($arg1 == 'order_id') {
215215
return $orderId;
216-
} elseif ($arg1 == 'invoice' && is_null($arg2)) {
216+
} elseif ($arg1 == 'invoice' && empty($arg2)) {
217217
return $invoiceData;
218218
}
219219
});

app/code/Magento/Theme/Test/Unit/Helper/StorageTest.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ public function testGetThumbnailPath(): void
202202
$thumbnailPath = '/' . implode(
203203
'/',
204204
[
205-
\Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE,
206-
\Magento\Theme\Model\Wysiwyg\Storage::THUMBNAIL_DIRECTORY,
207-
$image
208-
]
205+
\Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE,
206+
\Magento\Theme\Model\Wysiwyg\Storage::THUMBNAIL_DIRECTORY,
207+
$image
208+
]
209209
);
210210

211211
$this->customization->expects(
@@ -374,14 +374,9 @@ public function testGetRelativeUrl(): void
374374
};
375375
$this->urlDecoder
376376
->method('decode')
377-
->willReturnCallback(function ($arg) use ($decode, $notRoot, $filename) {
378-
if ($arg == $notRoot) {
379-
return $this->returnCallback($decode);
380-
}
381-
if ($arg == $filename) {
382-
return $this->returnCallback($decode);
383-
}
384-
});
377+
->withConsecutive([$notRoot], [$filename])
378+
->willReturnOnConsecutiveCalls($this->returnCallback($decode), $this->returnCallback($decode));
379+
385380
$this->assertEquals(
386381
'../image/not/a/root/filename.ext',
387382
$this->helper->getRelativeUrl()
@@ -391,7 +386,7 @@ public function testGetRelativeUrl(): void
391386
/**
392387
* @return array
393388
*/
394-
public static function getStorageTypeForNameDataProvider(): array
389+
public function getStorageTypeForNameDataProvider(): array
395390
{
396391
return [
397392
'font' => [\Magento\Theme\Model\Wysiwyg\Storage::TYPE_FONT, Storage::FONTS],
@@ -497,7 +492,7 @@ public function testGetCurrentPath(
497492
/**
498493
* @return array
499494
*/
500-
public static function getCurrentPathDataProvider(): array
495+
public function getCurrentPathDataProvider(): array
501496
{
502497
$rootPath = '/' . \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE;
503498

@@ -517,10 +512,14 @@ private function initializeDefaultRequestMock(): void
517512
{
518513
$this->request
519514
->method('getParam')
520-
->willReturnCallback(fn($param) => match ([$param]) {
521-
[Storage::PARAM_THEME_ID] => 6,
522-
[Storage::PARAM_CONTENT_TYPE] => \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE
523-
});
515+
->withConsecutive(
516+
[Storage::PARAM_THEME_ID],
517+
[Storage::PARAM_CONTENT_TYPE]
518+
)
519+
->willReturnOnConsecutiveCalls(
520+
6,
521+
\Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE
522+
);
524523
}
525524

526525
/**

0 commit comments

Comments
 (0)