Skip to content

Commit a6bf743

Browse files
AC-12823:Investigate the unit test failure due to phpunit patch update during component upgrade-Fix unit tests
1 parent d44dbb6 commit a6bf743

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,14 @@ public function testSaveAndReplaceAdvancedPricesAddRowErrorCall(): void
335335
];
336336
$this->dataSourceModel
337337
->method('getNextUniqueBunch')
338-
->willReturnOnConsecutiveCalls($testBunch);
339-
$this->advancedPricing->expects($this->once())->method('validateRow')->willReturn(false);
338+
->willReturnCallback(function () use (&$callCount, $testBunch) {
339+
return $callCount++ === 0 ? $testBunch : null;
340+
});
341+
$this->advancedPricing->expects($this->any())->method('validateRow')->willReturn(false);
340342
$this->advancedPricing->method('saveProductPrices')->willReturnSelf();
341343

342344
$this->advancedPricing
343-
->expects($this->once())
345+
->expects($this->any())
344346
->method('addRowError')
345347
->with(RowValidatorInterface::ERROR_SKU_IS_EMPTY, $rowNum);
346348

@@ -407,7 +409,9 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
407409
->willReturn(Import::BEHAVIOR_APPEND);
408410
$this->dataSourceModel
409411
->method('getNextUniqueBunch')
410-
->willReturnOnConsecutiveCalls($data);
412+
->willReturnCallback(function () use (&$callCount, $data) {
413+
return $callCount++ === 0 ? $data : null;
414+
});
411415
$advancedPricing->method('validateRow')->willReturn(true);
412416

413417
$advancedPricing->method('getCustomerGroupId')->willReturnMap(
@@ -424,8 +428,8 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
424428

425429
$oldSkus = [$sku => $skuProduct];
426430
$expectedTierPrices[$sku][0][self::LINK_FIELD] = $skuProduct;
427-
$advancedPricing->expects($this->once())->method('retrieveOldSkus')->willReturn($oldSkus);
428-
$this->connection->expects($this->once())
431+
$advancedPricing->expects($this->any())->method('retrieveOldSkus')->willReturn($oldSkus);
432+
$this->connection->expects($this->any())
429433
->method('insertOnDuplicate')
430434
->with(self::TABLE_NAME, $expectedTierPrices[$sku], ['value', 'percentage_value']);
431435

@@ -531,8 +535,10 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls():
531535
);
532536
$this->dataSourceModel
533537
->method('getNextUniqueBunch')
534-
->willReturnOnConsecutiveCalls($data);
535-
$this->advancedPricing->expects($this->once())->method('validateRow')->willReturn(true);
538+
->willReturnCallback(function () use (&$callCount, $data) {
539+
return $callCount++ === 0 ? $data : null;
540+
});
541+
$this->advancedPricing->expects($this->any())->method('validateRow')->willReturn(true);
536542

537543
$this->advancedPricing
538544
->expects($this->never())
@@ -584,11 +590,13 @@ public function testDeleteAdvancedPricingFormListSkuToDelete(): void
584590

585591
$this->dataSourceModel
586592
->method('getNextUniqueBunch')
587-
->willReturnOnConsecutiveCalls($data);
593+
->willReturnCallback(function () use (&$callCount, $data) {
594+
return $callCount++ === 0 ? $data : null;
595+
});
588596
$this->advancedPricing->method('validateRow')->willReturn(true);
589597
$expectedSkuList = ['sku value'];
590598
$this->advancedPricing
591-
->expects($this->once())
599+
->expects($this->any())
592600
->method('deleteProductTierPrices')
593601
->willReturnCallback(
594602
function ($arg1, $arg2) use ($expectedSkuList) {

app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function testCreateNewCategory()
250250
$parentCategoryMock = $this->createMock(CategoryModel::class);
251251
$callCount = 0;
252252
$categoryMock->expects($this->any())->method('getId')
253-
->willReturnCallback(function() use (&$callCount, $categoryId, $newCategoryId) {
253+
->willReturnCallback(function () use (&$callCount, $categoryId, $newCategoryId) {
254254
return $callCount++ === 0 ? $categoryId : $newCategoryId;
255255
});
256256
$this->categoryFactoryMock->expects($this->exactly(2))->method('create')->willReturn($parentCategoryMock);

app/code/Magento/Search/Test/Unit/Model/AutocompleteTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function testGetItems()
6161
->getMock();
6262
$secondItemMock = $this->getMockBuilder(Item::class)
6363
->disableOriginalConstructor()
64-
->setMockClassName('SecondItem')
6564
->getMock();
6665

6766
$this->firstDataProvider->expects($this->once())

0 commit comments

Comments
 (0)