@@ -333,16 +333,20 @@ public function testSaveAndReplaceAdvancedPricesAddRowErrorCall(): void
333
333
'bunch '
334
334
]
335
335
];
336
+ $ count = 0 ;
336
337
$ this ->dataSourceModel
337
338
->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
+ }
340
344
});
341
- $ this ->advancedPricing ->expects ($ this ->any ())->method ('validateRow ' )->willReturn (false );
345
+ $ this ->advancedPricing ->expects ($ this ->once ())->method ('validateRow ' )->willReturn (false );
342
346
$ this ->advancedPricing ->method ('saveProductPrices ' )->willReturnSelf ();
343
347
344
348
$ this ->advancedPricing
345
- ->expects ($ this ->any ())
349
+ ->expects ($ this ->once ())
346
350
->method ('addRowError ' )
347
351
->with (RowValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
348
352
@@ -407,10 +411,14 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
407
411
$ advancedPricing
408
412
->method ('getBehavior ' )
409
413
->willReturn (Import::BEHAVIOR_APPEND );
414
+ $ count = 0 ;
410
415
$ this ->dataSourceModel
411
416
->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
+ }
414
422
});
415
423
$ advancedPricing ->method ('validateRow ' )->willReturn (true );
416
424
@@ -428,8 +436,8 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
428
436
429
437
$ oldSkus = [$ sku => $ skuProduct ];
430
438
$ 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 ())
433
441
->method ('insertOnDuplicate ' )
434
442
->with (self ::TABLE_NAME , $ expectedTierPrices [$ sku ], ['value ' , 'percentage_value ' ]);
435
443
@@ -533,12 +541,17 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls():
533
541
$ this ->advancedPricing ->method ('getBehavior ' )->willReturn (
534
542
Import::BEHAVIOR_REPLACE
535
543
);
544
+
545
+ $ count = 0 ;
536
546
$ this ->dataSourceModel
537
547
->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
+ }
540
553
});
541
- $ this ->advancedPricing ->expects ($ this ->any ())->method ('validateRow ' )->willReturn (true );
554
+ $ this ->advancedPricing ->expects ($ this ->once ())->method ('validateRow ' )->willReturn (true );
542
555
543
556
$ this ->advancedPricing
544
557
->expects ($ this ->never ())
@@ -588,15 +601,19 @@ public function testDeleteAdvancedPricingFormListSkuToDelete(): void
588
601
]
589
602
];
590
603
604
+ $ count = 0 ;
591
605
$ this ->dataSourceModel
592
606
->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
+ }
595
612
});
596
613
$ this ->advancedPricing ->method ('validateRow ' )->willReturn (true );
597
614
$ expectedSkuList = ['sku value ' ];
598
615
$ this ->advancedPricing
599
- ->expects ($ this ->any ())
616
+ ->expects ($ this ->once ())
600
617
->method ('deleteProductTierPrices ' )
601
618
->willReturnCallback (
602
619
function ($ arg1 , $ arg2 ) use ($ expectedSkuList ) {
0 commit comments