Skip to content

Commit 99c5873

Browse files
committed
CE-33707: Fixed deprecated methods for PHPUnit v9.3.0
1 parent 6636b73 commit 99c5873

File tree

183 files changed

+8093
-6550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+8093
-6550
lines changed

app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Wysiwyg/DirectiveTest.php

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Cms\Test\Unit\Controller\Adminhtml\Wysiwyg;
99

10+
use Exception;
1011
use Magento\Backend\App\Action\Context;
1112
use Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive;
1213
use Magento\Cms\Model\Template\Filter;
@@ -17,7 +18,6 @@
1718
use Magento\Framework\Controller\Result\RawFactory;
1819
use Magento\Framework\Filesystem;
1920
use Magento\Framework\Filesystem\Directory\WriteInterface;
20-
use Magento\Framework\Filesystem\Driver\File;
2121
use Magento\Framework\Filesystem\DriverInterface;
2222
use Magento\Framework\Image\Adapter\AdapterInterface;
2323
use Magento\Framework\Image\AdapterFactory;
@@ -29,7 +29,7 @@
2929
use Psr\Log\LoggerInterface;
3030

3131
/**
32-
* @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive
32+
* @covers Directive
3333
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3434
*/
3535
class DirectiveTest extends TestCase
@@ -106,6 +106,9 @@ class DirectiveTest extends TestCase
106106
*/
107107
private $driverMock;
108108

109+
/**
110+
* @inheirtDoc
111+
*/
109112
protected function setUp(): void
110113
{
111114
$this->actionContextMock = $this->getMockBuilder(Context::class)
@@ -128,9 +131,8 @@ protected function setUp(): void
128131
->getMock();
129132
$this->imageAdapterMock = $this->getMockBuilder(AdapterInterface::class)
130133
->disableOriginalConstructor()
131-
->setMethods(
134+
->onlyMethods(
132135
[
133-
'getMimeType',
134136
'getColorAt',
135137
'getImage',
136138
'watermark',
@@ -144,10 +146,12 @@ protected function setUp(): void
144146
'rotate'
145147
]
146148
)
149+
->addMethods(['getMimeType'])
147150
->getMockForAbstractClass();
148151
$this->responseMock = $this->getMockBuilder(ResponseInterface::class)
149152
->disableOriginalConstructor()
150-
->setMethods(['setHeader', 'setBody', 'sendResponse'])
153+
->onlyMethods(['sendResponse'])
154+
->addMethods(['setHeader', 'setBody'])
151155
->getMockForAbstractClass();
152156
$this->wysiwygConfigMock = $this->getMockBuilder(Config::class)
153157
->disableOriginalConstructor()
@@ -156,7 +160,7 @@ protected function setUp(): void
156160
->disableOriginalConstructor()
157161
->getMockForAbstractClass();
158162
$this->rawFactoryMock = $this->getMockBuilder(RawFactory::class)
159-
->setMethods(['create'])
163+
->onlyMethods(['create'])
160164
->disableOriginalConstructor()
161165
->getMock();
162166
$this->rawMock = $this->getMockBuilder(Raw::class)
@@ -201,9 +205,10 @@ protected function setUp(): void
201205
}
202206

203207
/**
204-
* @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive::execute
208+
* @return void
209+
* @covers Directive::execute
205210
*/
206-
public function testExecute()
211+
public function testExecute(): void
207212
{
208213
$mimeType = 'image/jpeg';
209214
$imageBody = 'abcdefghijklmnopqrstuvwxyz0123456789';
@@ -243,26 +248,24 @@ public function testExecute()
243248
}
244249

245250
/**
246-
* @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive::execute
251+
* @return void
252+
* @covers Directive::execute
247253
*/
248-
public function testExecuteException()
254+
public function testExecuteException(): void
249255
{
250-
$exception = new \Exception('epic fail');
256+
$exception = new Exception('epic fail');
251257
$placeholderPath = 'pub/static/adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png';
252258
$mimeType = 'image/png';
253259
$imageBody = '0123456789abcdefghijklmnopqrstuvwxyz';
254260
$this->prepareExecuteTest();
255261

256-
$this->imageAdapterMock->expects($this->at(0))
257-
->method('open')
258-
->with(self::IMAGE_PATH)
259-
->willThrowException($exception);
260262
$this->wysiwygConfigMock->expects($this->once())
261263
->method('getSkinImagePlaceholderPath')
262264
->willReturn($placeholderPath);
263-
$this->imageAdapterMock->expects($this->at(1))
265+
$this->imageAdapterMock
264266
->method('open')
265-
->with($placeholderPath);
267+
->withConsecutive([self::IMAGE_PATH])
268+
->willThrowException($exception);
266269
$this->imageAdapterMock->expects($this->atLeastOnce())
267270
->method('getMimeType')
268271
->willReturn($mimeType);
@@ -297,7 +300,10 @@ public function testExecuteException()
297300
);
298301
}
299302

300-
protected function prepareExecuteTest()
303+
/**
304+
* @return void
305+
*/
306+
protected function prepareExecuteTest(): void
301307
{
302308
$directiveParam = 'e3ttZWRpYSB1cmw9Ind5c2l3eWcvYnVubnkuanBnIn19';
303309
$directive = '{{media url="wysiwyg/image.jpg"}}';
@@ -324,11 +330,12 @@ protected function prepareExecuteTest()
324330
/**
325331
* Test Execute With Deleted Image
326332
*
327-
* @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive::execute
333+
* @return void
334+
* @covers Directive::execute
328335
*/
329-
public function testExecuteWithDeletedImage()
336+
public function testExecuteWithDeletedImage(): void
330337
{
331-
$exception = new \Exception('epic fail');
338+
$exception = new Exception('epic fail');
332339
$placeholderPath = 'pub/static/adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png';
333340
$this->prepareExecuteTest();
334341

app/code/Magento/Cms/Test/Unit/Controller/Block/InlineEditTest.php

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,44 @@
2020

2121
class InlineEditTest extends TestCase
2222
{
23-
/** @var RequestInterface|MockObject */
23+
/**
24+
* @var RequestInterface|MockObject
25+
*/
2426
protected $request;
2527

26-
/** @var Block|MockObject */
28+
/**
29+
* @var Block|MockObject
30+
*/
2731
protected $cmsBlock;
2832

29-
/** @var Context|MockObject */
33+
/**
34+
* @var Context|MockObject
35+
*/
3036
protected $context;
3137

32-
/** @var BlockRepositoryInterface|MockObject */
38+
/**
39+
* @var BlockRepositoryInterface|MockObject
40+
*/
3341
protected $blockRepository;
3442

35-
/** @var JsonFactory|MockObject */
43+
/**
44+
* @var JsonFactory|MockObject
45+
*/
3646
protected $jsonFactory;
3747

38-
/** @var Json|MockObject */
48+
/**
49+
* @var Json|MockObject
50+
*/
3951
protected $resultJson;
4052

41-
/** @var InlineEdit */
53+
/**
54+
* @var InlineEdit
55+
*/
4256
protected $controller;
4357

58+
/**
59+
* @inheirtDoc
60+
*/
4461
protected function setUp(): void
4562
{
4663
$helper = new ObjectManager($this);
@@ -76,7 +93,10 @@ protected function setUp(): void
7693
);
7794
}
7895

79-
public function prepareMocksForTestExecute()
96+
/**
97+
* @return void
98+
*/
99+
public function prepareMocksForTestExecute(): void
80100
{
81101
$postData = [
82102
1 => [
@@ -85,14 +105,10 @@ public function prepareMocksForTestExecute()
85105
]
86106
];
87107

88-
$this->request->expects($this->at(0))
108+
$this->request
89109
->method('getParam')
90-
->with('isAjax')
91-
->willReturn(true);
92-
$this->request->expects($this->at(1))
93-
->method('getParam')
94-
->with('items', [])
95-
->willReturn($postData);
110+
->withConsecutive(['isAjax'], ['items', []])
111+
->willReturnOnConsecutiveCalls(true, $postData);
96112
$this->blockRepository->expects($this->once())
97113
->method('getById')
98114
->with(1)
@@ -116,7 +132,10 @@ public function prepareMocksForTestExecute()
116132
->willReturn($this->resultJson);
117133
}
118134

119-
public function testExecuteWithException()
135+
/**
136+
* @return void
137+
*/
138+
public function testExecuteWithException(): void
120139
{
121140
$this->prepareMocksForTestExecute();
122141
$this->blockRepository->expects($this->once())
@@ -125,38 +144,37 @@ public function testExecuteWithException()
125144
->willThrowException(new \Exception('Exception'));
126145
$this->resultJson->expects($this->once())
127146
->method('setData')
128-
->with([
129-
'messages' => [
130-
'[Block ID: 1] Exception'
131-
],
132-
'error' => true
133-
])
147+
->with(
148+
[
149+
'messages' => ['[Block ID: 1] Exception'],
150+
'error' => true
151+
]
152+
)
134153
->willReturnSelf();
135154

136155
$this->controller->execute();
137156
}
138157

139-
public function testExecuteWithoutData()
158+
/**
159+
* @return void
160+
*/
161+
public function testExecuteWithoutData(): void
140162
{
141-
$this->request->expects($this->at(0))
163+
$this->request
142164
->method('getParam')
143-
->with('isAjax')
144-
->willReturn(true);
145-
$this->request->expects($this->at(1))
146-
->method('getParam')
147-
->with('items', [])
148-
->willReturn([]);
165+
->withConsecutive(['isAjax'], ['items', []])
166+
->willReturnOnConsecutiveCalls(true, []);
149167
$this->jsonFactory->expects($this->once())
150168
->method('create')
151169
->willReturn($this->resultJson);
152170
$this->resultJson->expects($this->once())
153171
->method('setData')
154-
->with([
155-
'messages' => [
156-
'Please correct the data sent.'
157-
],
158-
'error' => true
159-
])
172+
->with(
173+
[
174+
'messages' => ['Please correct the data sent.'],
175+
'error' => true
176+
]
177+
)
160178
->willReturnSelf();
161179

162180
$this->controller->execute();

0 commit comments

Comments
 (0)