Skip to content

Commit ff93549

Browse files
committed
AC-10821: Static Test fixes
1 parent 831ef30 commit ff93549

File tree

6 files changed

+38
-42
lines changed

6 files changed

+38
-42
lines changed

app/code/Magento/Backend/Test/Unit/Block/Page/System/Config/Robots/ResetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function setUp(): void
5555
}
5656

5757
/**
58-
* @covers Reset::getRobotsDefaultCustomInstructions
58+
* @covers \Magento\Backend\Block\Page\System\Config\Robots\Reset::getRobotsDefaultCustomInstructions
5959
*/
6060
public function testGetRobotsDefaultCustomInstructions()
6161
{

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,14 @@ protected function setUp(): void
125125
);
126126
$this->resultMock = $this->getMockBuilder(DataObject::class)
127127
->addMethods(
128-
['getItemIsQtyDecimal', 'getHasQtyOptionUpdate', 'getOrigQty', 'getMessage', 'getItemBackorders', 'getItemQty']
128+
[
129+
'getItemIsQtyDecimal',
130+
'getHasQtyOptionUpdate',
131+
'getOrigQty',
132+
'getMessage',
133+
'getItemBackorders',
134+
'getItemQty'
135+
]
129136
)
130137
->disableOriginalConstructor()
131138
->getMock();

app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ protected function setUp(): void
123123
->addMethods(
124124
[
125125
'setStockStatusChangedAutomaticallyFlag',
126-
'hasStockStatusChangedAutomaticallyFlag',
127-
126+
'getStockStatusChangedAutomaticallyFlag',
127+
'hasStockStatusChangedAutomaticallyFlag'
128128
]
129129
)
130130
->onlyMethods(
@@ -331,7 +331,7 @@ public function testSave(
331331
'setStockId' => ['expects' => $this->once(), 'with' => [1], 'willReturnSelf' => true,],
332332
'setLowStockDate' => [
333333
'expects' => $this->exactly(2),
334-
'withConsecutive' => [[null], [$date],],
334+
'willReturnCallback' => [[null], [$date],],
335335
'willReturnSelf' => true,
336336
],
337337
'hasStockStatusChangedAutomaticallyFlag' => ['expects' => $this->once(), 'willReturn' => false,],
@@ -427,7 +427,7 @@ public function testGetList()
427427
/**
428428
* @return array
429429
*/
430-
public function saveDataProvider(): array
430+
public static function saveDataProvider(): array
431431
{
432432
return [
433433
'should set isInStock=true if: verifyStock=true, isInStock=false, stockStatusChangedAuto=true' => [
@@ -438,55 +438,55 @@ public function saveDataProvider(): array
438438
'should not set isInStock=true if: verifyStock=true, isInStock=false, stockStatusChangedAuto=false' => [
439439
'stockStateProviderMockConfig' => [],
440440
'stockItemMockConfig' => [
441-
'setIsInStock' => ['expects' => $this->never(),],
442-
'setStockStatusChangedAuto' => ['expects' => $this->never()],
443-
'getStockStatusChangedAuto' => ['expects' => $this->once(), 'willReturn' => false,],
441+
'setIsInStock' => ['expects' => self::never(),],
442+
'setStockStatusChangedAuto' => ['expects' => self::never()],
443+
'getStockStatusChangedAuto' => ['expects' => self::once(), 'willReturn' => false,],
444444
],
445445
'existingStockItemMockConfig' => [],
446446
],
447447
'should set isInStock=false and stockStatusChangedAuto=true if: verifyStock=false and isInStock=true' => [
448448
'stockStateProviderMockConfig' => [
449-
'verifyStock' => ['expects' => $this->once(), 'willReturn' => false,],
449+
'verifyStock' => ['expects' => self::once(), 'willReturn' => false,],
450450
],
451451
'stockItemMockConfig' => [
452-
'getIsInStock' => ['expects' => $this->any(), 'willReturn' => true,],
453-
'getStockStatusChangedAuto' => ['expects' => $this->never(),],
454-
'setIsInStock' => ['expects' => $this->once(), 'with' => [false],],
455-
'setStockStatusChangedAuto' => ['expects' => $this->once(), 'with' => [1],],
452+
'getIsInStock' => ['expects' => self::any(), 'willReturn' => true,],
453+
'getStockStatusChangedAuto' => ['expects' => self::never(),],
454+
'setIsInStock' => ['expects' => self::once(), 'with' => [false],],
455+
'setStockStatusChangedAuto' => ['expects' => self::once(), 'with' => [1],],
456456
],
457457
'existingStockItemMockConfig' => [],
458458
],
459459
'should set stockStatusChangedAuto=true if: verifyStock=false and isInStock=false' => [
460460
'stockStateProviderMockConfig' => [
461-
'verifyStock' => ['expects' => $this->once(), 'willReturn' => false,],
461+
'verifyStock' => ['expects' => self::once(), 'willReturn' => false,],
462462
],
463463
'stockItemMockConfig' => [
464-
'getIsInStock' => ['expects' => $this->any(), 'willReturn' => false,],
465-
'getStockStatusChangedAuto' => ['expects' => $this->never(),],
466-
'setIsInStock' => ['expects' => $this->never(),],
467-
'setStockStatusChangedAuto' => ['expects' => $this->never(),],
464+
'getIsInStock' => ['expects' => self::any(), 'willReturn' => false,],
465+
'getStockStatusChangedAuto' => ['expects' => self::never(),],
466+
'setIsInStock' => ['expects' => self::never(),],
467+
'setStockStatusChangedAuto' => ['expects' => self::never(),],
468468
],
469469
'existingStockItemMockConfig' => [],
470470
],
471471
'should set stockStatusChangedAuto=true if: stockStatusChangedAutomaticallyFlag=true' => [
472472
'stockStateProviderMockConfig' => [],
473473
'stockItemMockConfig' => [
474-
'getStockStatusChangedAuto' => ['expects' => $this->once(), 'willReturn' => false,],
475-
'setIsInStock' => ['expects' => $this->never(),],
476-
'setStockStatusChangedAuto' => ['expects' => $this->once(), 'with' => [1],],
477-
'hasStockStatusChangedAutomaticallyFlag' => ['expects' => $this->once(), 'willReturn' => true,],
478-
'getStockStatusChangedAutomaticallyFlag' => ['expects' => $this->once(), 'willReturn' => true,],
474+
'getStockStatusChangedAuto' => ['expects' =>self::once(), 'willReturn' => false,],
475+
'setIsInStock' => ['expects' => self::never(),],
476+
'setStockStatusChangedAuto' => ['expects' => self::once(), 'with' => [1],],
477+
'hasStockStatusChangedAutomaticallyFlag' => ['expects' => self::once(), 'willReturn' => true,],
478+
'getStockStatusChangedAutomaticallyFlag' => ['expects' => self::once(), 'willReturn' => true,],
479479
],
480480
'existingStockItemMockConfig' => [
481481
],
482482
],
483483
'should set stockStatusChangedAuto=false if: getManageStock=false' => [
484484
'stockStateProviderMockConfig' => [],
485485
'stockItemMockConfig' => [
486-
'getManageStock' => ['expects' => $this->once(), 'willReturn' => false],
487-
'getStockStatusChangedAuto' => ['expects' => $this->never(), 'willReturn' => false,],
488-
'setIsInStock' => ['expects' => $this->never(),],
489-
'setStockStatusChangedAuto' => ['expects' => $this->once(), 'with' => [0],],
486+
'getManageStock' => ['expects' => self::once(), 'willReturn' => false],
487+
'getStockStatusChangedAuto' => ['expects' => self::never(), 'willReturn' => false,],
488+
'setIsInStock' => ['expects' => self::never(),],
489+
'setStockStatusChangedAuto' => ['expects' => self::once(), 'with' => [0],],
490490
],
491491
'existingStockItemMockConfig' => [
492492
],
@@ -506,10 +506,8 @@ private function configMock(MockObject $mockObject, array $configs): void
506506
if (isset($config['with'])) {
507507
$mockMethod->with(...$config['with']);
508508
}
509-
if (isset($config['withConsecutive'])) {
510-
$mockMethod->willReturnCallback(fn($param) => match ([$param]) {
511-
[...$config['withConsecutive']] => $mockMethod
512-
});
509+
if (isset($config['willReturnCallback'])) {
510+
$mockMethod->willReturnCallback(...$config['willReturnCallback']);
513511
}
514512
if (isset($config['willReturnSelf'])) {
515513
$mockMethod->willReturnSelf();

app/code/Magento/CatalogRule/Test/Unit/Observer/ProcessAdminFinalPriceObserverTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,21 @@ class ProcessAdminFinalPriceObserverTest extends TestCase
3535
private $observer;
3636

3737
/**
38-
* Store Manager mock
39-
*
4038
* @var StoreManagerInterface
4139
*/
4240
private $storeManagerMock;
4341

4442
/**
45-
* Locale Date mock
46-
*
4743
* @var TimezoneInterface
4844
*/
4945
private $localeDateMock;
5046

5147
/**
52-
* Resource Rule Factory mock
53-
*
5448
* @var RuleFactory
5549
*/
5650
private $resourceRuleFactoryMock;
5751

5852
/**
59-
* Rule Prices Storage mock
60-
*
6153
* @var RulePricesStorage
6254
*/
6355
private $rulePricesStorageMock;

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Storage/DynamicStorageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public function testFindProductRewriteByRequestPath(
198198

199199
/**
200200
* @return array
201+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
201202
*/
202203
public function findProductRewriteByRequestPathDataProvider(): array
203204
{

app/code/Magento/Checkout/Test/Unit/Block/Shipping/PriceTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
class PriceTest extends TestCase
2020
{
21-
const SUBTOTAL = 10;
22-
2321
/**
2422
* @var Price
2523
*/

0 commit comments

Comments
 (0)