Skip to content

Commit e0c61de

Browse files
committed
33916: Eliminated calls deprecated methods of the phpunit/phpunit
1 parent 5c9a777 commit e0c61de

File tree

25 files changed

+1342
-1044
lines changed

25 files changed

+1342
-1044
lines changed

app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ class CurlTest extends TestCase
5050
private $converterMock;
5151

5252
/**
53-
* @return void
53+
* @inheritdoc
5454
*/
5555
protected function setUp(): void
5656
{
5757
$this->curlAdapterMock = $this->createMock(\Magento\Framework\HTTP\Adapter\Curl::class);
5858

5959
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
6060
$curlFactoryMock = $this->getMockBuilder(CurlFactory::class)
61-
->setMethods(['create'])
61+
->onlyMethods(['create'])
6262
->disableOriginalConstructor()
6363
->getMock();
6464
$curlFactoryMock
@@ -76,7 +76,7 @@ protected function setUp(): void
7676
'curlFactory' => $curlFactoryMock,
7777
'responseFactory' => $this->responseFactoryMock,
7878
'converter' => $this->converterMock,
79-
'logger' => $this->loggerMock,
79+
'logger' => $this->loggerMock
8080
]
8181
);
8282
}
@@ -94,7 +94,7 @@ public function getTestData()
9494
'version' => '1.1',
9595
'body'=> ['name' => 'value'],
9696
'url' => 'http://www.mystore.com',
97-
'method' => ZendClient::POST,
97+
'method' => ZendClient::POST
9898
]
9999
]
100100
];
@@ -122,14 +122,8 @@ public function testRequestSuccess(array $data)
122122
$this->curlAdapterMock->expects($this->once())
123123
->method('read')
124124
->willReturn($responseString);
125-
$this->curlAdapterMock
126-
->method('getErrno')
127-
->willReturn(0);
128-
129-
$this->responseFactoryMock
130-
->method('create')
131-
->with($responseString)
132-
->willReturn($response);
125+
$this->curlAdapterMock->method('getErrno')->willReturn(0);
126+
$this->responseFactoryMock->method('create')->with($responseString)->willReturn($response);
133127

134128
$this->assertEquals(
135129
$response,
@@ -196,7 +190,7 @@ public function testRequestError(array $data)
196190
private function createJsonConverter()
197191
{
198192
$converterMock = $this->getMockBuilder(JsonConverter::class)
199-
->setMethodsExcept(['getContentTypeHeader'])
193+
->onlyMethods(['getContentTypeHeader','toBody'])
200194
->disableOriginalConstructor()
201195
->getMock();
202196
$converterMock->method('toBody')->willReturnCallback(function ($value) {

app/code/Magento/Backup/Test/Unit/Model/Fs/CollectionTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
class CollectionTest extends TestCase
1919
{
20-
public function testConstructor()
20+
/**
21+
* @return void
22+
*/
23+
public function testConstructor(): void
2124
{
2225
$helper = new ObjectManager($this);
2326
$filesystem = $this->getMockBuilder(Filesystem::class)
@@ -39,8 +42,9 @@ public function testConstructor()
3942
)->disableOriginalConstructor()
4043
->getMock();
4144
$directoryWrite->expects($this->any())->method('create')->with('backups');
42-
$directoryWrite->expects($this->any())->method('getAbsolutePath')->willReturn('');
43-
$directoryWrite->expects($this->at(3))->method('getAbsolutePath')->with('backups');
45+
$directoryWrite->method('getAbsolutePath')
46+
->withConsecutive([], [], ['backups'])
47+
->willReturnOnConsecutiveCalls('', '');
4448
$directoryWrite->expects($this->any())->method('isDirectory')->willReturn(true);
4549
$directoryWrite->expects($this->any())->method('getDriver')->willReturn($driver);
4650
$targetDirectory = $this->getMockBuilder(TargetDirectory::class)

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ class SaveTest extends TestCase
8282
private $save;
8383

8484
/**
85-
* Set up
85+
* Set up.
8686
*
87-
* @return void
87+
* @inheritdoc
8888
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
8989
*/
9090
protected function setUp(): void
@@ -144,17 +144,17 @@ protected function setUp(): void
144144
}
145145

146146
/**
147-
* Run test execute method
147+
* Run test execute method.
148148
*
149149
* @param int|bool $categoryId
150150
* @param int $storeId
151151
* @param int|null $parentId
152-
* @return void
153152
*
153+
* @return void
154154
* @dataProvider dataProviderExecute
155155
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
156156
*/
157-
public function testExecute($categoryId, $storeId, $parentId)
157+
public function testExecute($categoryId, $storeId, $parentId): void
158158
{
159159
$this->markTestSkipped('Due to MAGETWO-48956');
160160

@@ -407,9 +407,7 @@ public function testExecute($categoryId, $storeId, $parentId)
407407
$this->messageManagerMock->expects($this->once())
408408
->method('addSuccessMessage')
409409
->with(__('You saved the category.'));
410-
$categoryMock->expects($this->at(1))
411-
->method('getId')
412-
->willReturn(111);
410+
$categoryMock->method('getId')->willReturn(111);
413411
$this->layoutFactoryMock->expects($this->once())
414412
->method('create')
415413
->willReturn($layoutMock);
@@ -449,30 +447,30 @@ public function testExecute($categoryId, $storeId, $parentId)
449447
}
450448

451449
/**
452-
* Data provider for execute
450+
* Data provider for execute.
453451
*
454452
* @return array
455453
*/
456-
public function dataProviderExecute()
454+
public function dataProviderExecute(): array
457455
{
458456
return [
459457
[
460458
'categoryId' => false,
461459
'storeId' => 7,
462-
'parentId' => 123,
460+
'parentId' => 123
463461
],
464462
[
465463
'categoryId' => false,
466464
'storeId' => 7,
467-
'parentId' => null,
465+
'parentId' => null
468466
]
469467
];
470468
}
471469

472470
/**
473471
* @return array
474472
*/
475-
public function imagePreprocessingDataProvider()
473+
public function imagePreprocessingDataProvider(): array
476474
{
477475
$dataWithImage = [
478476
'image' => 'path.jpg',
@@ -502,7 +500,7 @@ public function imagePreprocessingDataProvider()
502500
* @param array $data
503501
* @param array $expected
504502
*/
505-
public function testImagePreprocessing($data, $expected)
503+
public function testImagePreprocessing($data, $expected): void
506504
{
507505
$eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
508506

0 commit comments

Comments
 (0)