Skip to content

Commit f34b76b

Browse files
CE-33709: Fixed errors after upgrade to PHPUnit v9.5.8
1 parent 8e55e3e commit f34b76b

File tree

9 files changed

+119
-60
lines changed

9 files changed

+119
-60
lines changed

app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class PriceTest extends TestCase
7070

7171
private $tierPriceExtensionFactoryMock;
7272

73+
/**
74+
* @inheritdoc
75+
*/
7376
protected function setUp(): void
7477
{
7578
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -129,9 +132,10 @@ protected function setUp(): void
129132
/**
130133
* testGetTierPricesWithNull
131134
*
135+
* @return void
132136
* @dataProvider nullPricesDataProvider
133137
*/
134-
public function testGetPricesWithNull($key, $getter)
138+
public function testGetPricesWithNull($key, $getter): void
135139
{
136140
// test when we don't send anything in, that no data changes
137141
$someValue = 'any fake value';
@@ -145,7 +149,7 @@ public function testGetPricesWithNull($key, $getter)
145149
/**
146150
* @return array
147151
*/
148-
public function nullPricesDataProvider()
152+
public function nullPricesDataProvider(): array
149153
{
150154
return [
151155
'testGetTierPricesWithNull' => [$this::KEY_TIER_PRICE, 'setTierPrices']
@@ -155,7 +159,7 @@ public function nullPricesDataProvider()
155159
/**
156160
* @return array
157161
*/
158-
public function pricesDataProvider()
162+
public function pricesDataProvider(): array
159163
{
160164
return [
161165
'global price scope' => [$this::PRICE_SCOPE_GLOBAL, 0],
@@ -167,9 +171,10 @@ public function pricesDataProvider()
167171
* testGetTierPrices
168172
* testSetTierPrices
169173
*
174+
* @return void
170175
* @dataProvider pricesDataProvider
171176
*/
172-
public function testTierPrices($priceScope, $expectedWebsiteId)
177+
public function testTierPrices($priceScope, $expectedWebsiteId): void
173178
{
174179
// establish the behavior of the mocks
175180
$this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn($priceScope);
@@ -262,7 +267,7 @@ function () {
262267
}
263268

264269
/**
265-
* Get tier price with percent value type
270+
* Get tier price with percent value type.
266271
*
267272
* @return void
268273
*/
@@ -305,7 +310,7 @@ private function getProductTierPriceExtensionInterfaceMock(): MockObject
305310
$mockBuilder = $this->getMockBuilder(ProductTierPriceExtensionInterface::class)
306311
->disableOriginalConstructor();
307312
try {
308-
$mockBuilder->addMethods(['getPercentageValue', 'setPercentageValue', 'setWebsiteId', 'getWebsiteId']);
313+
$mockBuilder->onlyMethods(['getPercentageValue', 'setPercentageValue', 'setWebsiteId', 'getWebsiteId']);
309314
} catch (RuntimeException $e) {
310315
// ProductTierPriceExtensionInterface already generated and has all necessary methods.
311316
}

app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function setUp(): void
149149
'importCustomerAddressData',
150150
'save',
151151
'getShippingRateByCode',
152-
'getShippingMethod',
152+
'getShippingMethod'
153153
]
154154
)
155155
->disableOriginalConstructor()
@@ -168,7 +168,7 @@ protected function setUp(): void
168168
'collectTotals',
169169
'getExtensionAttributes',
170170
'setExtensionAttributes',
171-
'setBillingAddress',
171+
'setBillingAddress'
172172
]
173173
)
174174
->disableOriginalConstructor()
@@ -195,7 +195,7 @@ protected function setUp(): void
195195
'shippingAssignmentFactory' => $this->shippingAssignmentFactoryMock,
196196
'cartExtensionFactory' => $this->cartExtensionFactoryMock,
197197
'shippingFactory' => $this->shippingFactoryMock,
198-
'addressValidator' => $this->addressValidatorMock,
198+
'addressValidator' => $this->addressValidatorMock
199199
]
200200
);
201201
}
@@ -227,9 +227,10 @@ public function testSaveAddressInformationIfCartIsEmpty(): void
227227
}
228228

229229
/**
230-
* Sets shipping assignments
230+
* Sets shipping assignments.
231231
*
232232
* @param string $shippingMethod
233+
*
233234
* @return void
234235
*/
235236
private function setShippingAssignmentsMocks($shippingMethod): void
@@ -286,7 +287,7 @@ private function setShippingAssignmentsMocks($shippingMethod): void
286287
}
287288

288289
/**
289-
* Save address with `StateException`
290+
* Save address with `StateException`.
290291
*
291292
* @return void
292293
*/
@@ -317,7 +318,7 @@ public function testSaveAddressInformationIfShippingAddressNotSet(): void
317318
}
318319

319320
/**
320-
* Save address with `LocalizedException`
321+
* Save address with `LocalizedException`.
321322
*
322323
* @return void
323324
*/
@@ -385,7 +386,7 @@ public function testSaveAddressInformationWithLocalizedException(): void
385386
}
386387

387388
/**
388-
* Save address with `InputException`
389+
* Save address with `InputException`.
389390
*
390391
* @return void
391392
*/
@@ -450,7 +451,7 @@ public function testSaveAddressInformationIfCanNotSaveQuote(): void
450451
}
451452

452453
/**
453-
* Save address with `NoSuchEntityException`
454+
* Save address with `NoSuchEntityException`.
454455
*
455456
* @return void
456457
*/
@@ -525,7 +526,7 @@ public function testSaveAddressInformationIfCarrierCodeIsInvalid(): void
525526
}
526527

527528
/**
528-
* Save address info test
529+
* Save address info test.
529530
*
530531
* @return void
531532
*/
@@ -631,7 +632,7 @@ private function getCartExtensionMock(): MockObject
631632
{
632633
$mockBuilder = $this->getMockBuilder(CartExtension::class);
633634
try {
634-
$mockBuilder->addMethods(['getShippingAssignments', 'setShippingAssignments']);
635+
$mockBuilder->onlyMethods(['getShippingAssignments', 'setShippingAssignments']);
635636
} catch (RuntimeException $e) {
636637
// CartExtension already generated.
637638
}

app/code/Magento/Cms/Test/Unit/Model/Template/FilterProviderTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class FilterProviderTest extends TestCase
3030
*/
3131
protected $_filterMock;
3232

33+
/**
34+
* @inheritdoc
35+
*/
3336
protected function setUp(): void
3437
{
3538
$this->_filterMock = $this->createMock(Filter::class);
@@ -39,38 +42,44 @@ protected function setUp(): void
3942
}
4043

4144
/**
45+
* @return void
4246
* @covers \Magento\Cms\Model\Template\FilterProvider::getBlockFilter
4347
*/
44-
public function testGetBlockFilter()
48+
public function testGetBlockFilter(): void
4549
{
4650
$this->assertInstanceOf(Filter::class, $this->_model->getBlockFilter());
4751
}
4852

4953
/**
54+
* @return void
5055
* @covers \Magento\Cms\Model\Template\FilterProvider::getPageFilter
5156
*/
52-
public function testGetPageFilter()
57+
public function testGetPageFilter(): void
5358
{
5459
$this->assertInstanceOf(Filter::class, $this->_model->getPageFilter());
5560
}
5661

5762
/**
63+
* @return void
5864
* @covers \Magento\Cms\Model\Template\FilterProvider::getPageFilter
5965
*/
60-
public function testGetPageFilterInnerCache()
66+
public function testGetPageFilterInnerCache(): void
6167
{
6268
$this->_objectManagerMock->expects($this->once())->method('get')->willReturn($this->_filterMock);
6369
$this->_model->getPageFilter();
6470
$this->_model->getPageFilter();
6571
}
6672

6773
/**
74+
* @return void
6875
* @covers \Magento\Cms\Model\Template\FilterProvider::getPageFilter
6976
*/
70-
public function testGetPageWrongInstance()
77+
public function testGetPageWrongInstance(): void
7178
{
7279
$this->expectException('Exception');
73-
$someClassMock = $this->createMock('SomeClass');
80+
$someClassMock = $this->getMockBuilder('SomeClass')
81+
->allowMockingUnknownTypes()
82+
->getMock();
7483
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
7584
$objectManagerMock->expects($this->once())->method('get')->willReturn($someClassMock);
7685
$model = new FilterProvider($objectManagerMock, 'SomeClass', 'SomeClass');

app/code/Magento/Downloadable/Test/Unit/Model/Link/UpdateHandlerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Downloadable\Test\Unit\Model\Link;
@@ -120,7 +119,7 @@ public function testExecute(): void
120119
}
121120

122121
/**
123-
* Update links for non downloadable product
122+
* Update links for non downloadable product.
124123
*
125124
* @return void
126125
*/
@@ -157,7 +156,7 @@ private function getProductExtensionMock(): MockObject
157156
$mockBuilder = $this->getMockBuilder(ProductExtensionInterface::class)
158157
->disableOriginalConstructor();
159158
try {
160-
$mockBuilder->addMethods(['getDownloadableProductLinks']);
159+
$mockBuilder->onlyMethods(['getDownloadableProductLinks']);
161160
} catch (RuntimeException $e) {
162161
// ProductExtension already generated.
163162
}

app/code/Magento/Downloadable/Test/Unit/Model/Sample/UpdateHandlerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Downloadable\Test\Unit\Model\Sample;
@@ -71,7 +70,7 @@ protected function setUp(): void
7170
}
7271

7372
/**
74-
* Update samples for downloadable product
73+
* Update samples for downloadable product.
7574
*
7675
* @return void
7776
*/
@@ -120,7 +119,7 @@ public function testExecute(): void
120119
}
121120

122121
/**
123-
* Update samples for non downloadable product
122+
* Update samples for non downloadable product.
124123
*
125124
* @return void
126125
*/
@@ -157,7 +156,7 @@ private function getProductExtensionMock(): MockObject
157156
$mockBuilder = $this->getMockBuilder(ProductExtensionInterface::class)
158157
->disableOriginalConstructor();
159158
try {
160-
$mockBuilder->addMethods(['getDownloadableProductSamples']);
159+
$mockBuilder->onlyMethods(['getDownloadableProductSamples']);
161160
} catch (RuntimeException $e) {
162161
// Product extension already generated.
163162
}

app/code/Magento/Multishipping/Test/Unit/Model/DisableMultishippingTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ protected function setUp(): void
4545
* Test 'execute' method if 'MultiShipping' mode is enabled.
4646
*
4747
* @param bool $hasShippingAssignments
48+
*
4849
* @return void
4950
* @dataProvider executeWithMultishippingModeEnabledDataProvider
5051
*/
@@ -121,7 +122,7 @@ private function getCartExtensionMock(): MockObject
121122
$mockBuilder = $this->getMockBuilder(CartExtensionInterface::class)
122123
->disableOriginalConstructor();
123124
try {
124-
$mockBuilder->addMethods(['getShippingAssignments', 'setShippingAssignments']);
125+
$mockBuilder->onlyMethods(['getShippingAssignments', 'setShippingAssignments']);
125126
} catch (RuntimeException $e) {
126127
// CartExtension already generated.
127128
}

0 commit comments

Comments
 (0)