@@ -333,16 +333,20 @@ public function testSaveAndReplaceAdvancedPricesAddRowErrorCall(): void
333333 'bunch '
334334 ]
335335 ];
336+ $ count = 0 ;
336337 $ this ->dataSourceModel
337338 ->method ('getNextUniqueBunch ' )
338- ->willReturnCallback (function () use (&$ callCount , $ testBunch ) {
339- return $ callCount ++ === 0 ? $ testBunch : null ;
339+ ->willReturnCallback (function () use (&$ count , $ testBunch ) {
340+ if ($ count == 0 ) {
341+ $ count ++;
342+ return $ testBunch ;
343+ }
340344 });
341- $ this ->advancedPricing ->expects ($ this ->any ())->method ('validateRow ' )->willReturn (false );
345+ $ this ->advancedPricing ->expects ($ this ->once ())->method ('validateRow ' )->willReturn (false );
342346 $ this ->advancedPricing ->method ('saveProductPrices ' )->willReturnSelf ();
343347
344348 $ this ->advancedPricing
345- ->expects ($ this ->any ())
349+ ->expects ($ this ->once ())
346350 ->method ('addRowError ' )
347351 ->with (RowValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
348352
@@ -407,10 +411,14 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
407411 $ advancedPricing
408412 ->method ('getBehavior ' )
409413 ->willReturn (Import::BEHAVIOR_APPEND );
414+ $ count = 0 ;
410415 $ this ->dataSourceModel
411416 ->method ('getNextUniqueBunch ' )
412- ->willReturnCallback (function () use (&$ callCount , $ data ) {
413- return $ callCount ++ === 0 ? $ data : null ;
417+ ->willReturnCallback (function () use (&$ count , $ data ) {
418+ if ($ count == 0 ) {
419+ $ count ++;
420+ return $ data ;
421+ }
414422 });
415423 $ advancedPricing ->method ('validateRow ' )->willReturn (true );
416424
@@ -428,8 +436,8 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
428436
429437 $ oldSkus = [$ sku => $ skuProduct ];
430438 $ expectedTierPrices [$ sku ][0 ][self ::LINK_FIELD ] = $ skuProduct ;
431- $ advancedPricing ->expects ($ this ->any ())->method ('retrieveOldSkus ' )->willReturn ($ oldSkus );
432- $ this ->connection ->expects ($ this ->any ())
439+ $ advancedPricing ->expects ($ this ->once ())->method ('retrieveOldSkus ' )->willReturn ($ oldSkus );
440+ $ this ->connection ->expects ($ this ->once ())
433441 ->method ('insertOnDuplicate ' )
434442 ->with (self ::TABLE_NAME , $ expectedTierPrices [$ sku ], ['value ' , 'percentage_value ' ]);
435443
@@ -533,12 +541,17 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls():
533541 $ this ->advancedPricing ->method ('getBehavior ' )->willReturn (
534542 Import::BEHAVIOR_REPLACE
535543 );
544+
545+ $ count = 0 ;
536546 $ this ->dataSourceModel
537547 ->method ('getNextUniqueBunch ' )
538- ->willReturnCallback (function () use (&$ callCount , $ data ) {
539- return $ callCount ++ === 0 ? $ data : null ;
548+ ->willReturnCallback (function () use (&$ count , $ data ) {
549+ if ($ count == 0 ) {
550+ $ count ++;
551+ return $ data ;
552+ }
540553 });
541- $ this ->advancedPricing ->expects ($ this ->any ())->method ('validateRow ' )->willReturn (true );
554+ $ this ->advancedPricing ->expects ($ this ->once ())->method ('validateRow ' )->willReturn (true );
542555
543556 $ this ->advancedPricing
544557 ->expects ($ this ->never ())
@@ -588,15 +601,19 @@ public function testDeleteAdvancedPricingFormListSkuToDelete(): void
588601 ]
589602 ];
590603
604+ $ count = 0 ;
591605 $ this ->dataSourceModel
592606 ->method ('getNextUniqueBunch ' )
593- ->willReturnCallback (function () use (&$ callCount , $ data ) {
594- return $ callCount ++ === 0 ? $ data : null ;
607+ ->willReturnCallback (function () use (&$ count , $ data ) {
608+ if ($ count == 0 ) {
609+ $ count ++;
610+ return $ data ;
611+ }
595612 });
596613 $ this ->advancedPricing ->method ('validateRow ' )->willReturn (true );
597614 $ expectedSkuList = ['sku value ' ];
598615 $ this ->advancedPricing
599- ->expects ($ this ->any ())
616+ ->expects ($ this ->once ())
600617 ->method ('deleteProductTierPrices ' )
601618 ->willReturnCallback (
602619 function ($ arg1 , $ arg2 ) use ($ expectedSkuList ) {
0 commit comments