3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
namespace tests \unit \Magento \FunctionalTestFramework \Util ;
8
9
9
- use AspectMock \ Test as AspectMock ;
10
+ use ReflectionProperty ;
10
11
use tests \unit \Util \MagentoTestCase ;
11
12
use Magento \FunctionalTestingFramework \Util \GenerationErrorHandler ;
12
13
use Magento \FunctionalTestingFramework \Config \MftfApplicationConfig ;
@@ -21,10 +22,10 @@ class GenerationErrorHandlerTest extends MagentoTestCase
21
22
*/
22
23
public function testGetDistinctErrors ()
23
24
{
24
- AspectMock:: double (
25
- MftfApplicationConfig::class,
26
- [ 'getPhase ' => MftfApplicationConfig:: GENERATION_PHASE ]
27
- );
25
+ $ this -> createMock (MftfApplicationConfig::class)
26
+ -> expects ( $ this -> once ())
27
+ -> method ( 'getPhase ' )
28
+ -> willReturn (MftfApplicationConfig:: GENERATION_PHASE );
28
29
29
30
$ expectedAllErrors = [
30
31
'test ' => [
@@ -79,10 +80,10 @@ public function testGetDistinctErrors()
79
80
*/
80
81
public function testGetErrorsWithSameKey ()
81
82
{
82
- AspectMock:: double (
83
- MftfApplicationConfig::class,
84
- [ 'getPhase ' => MftfApplicationConfig:: GENERATION_PHASE ]
85
- );
83
+ $ this -> createMock (MftfApplicationConfig::class)
84
+ -> expects ( $ this -> once ())
85
+ -> method ( 'getPhase ' )
86
+ -> willReturn (MftfApplicationConfig:: GENERATION_PHASE );
86
87
87
88
$ expectedAllErrors = [
88
89
'test ' => [
@@ -163,10 +164,10 @@ public function testGetErrorsWithSameKey()
163
164
*/
164
165
public function testGetAllErrorsDuplicate ()
165
166
{
166
- AspectMock:: double (
167
- MftfApplicationConfig::class,
168
- [ 'getPhase ' => MftfApplicationConfig:: GENERATION_PHASE ]
169
- );
167
+ $ this -> createMock (MftfApplicationConfig::class)
168
+ -> expects ( $ this -> once ())
169
+ -> method ( 'getPhase ' )
170
+ -> willReturn (MftfApplicationConfig:: GENERATION_PHASE );
170
171
171
172
$ expectedAllErrors = [
172
173
'test ' => [
@@ -254,7 +255,7 @@ public function testGetAllErrorMessages($expectedErrMessages, $errors)
254
255
$ handler = GenerationErrorHandler::getInstance ();
255
256
$ handler ->reset ();
256
257
257
- $ property = new \ ReflectionProperty (GenerationErrorHandler::class, 'errors ' );
258
+ $ property = new ReflectionProperty (GenerationErrorHandler::class, 'errors ' );
258
259
$ property ->setAccessible (true );
259
260
$ property ->setValue ($ handler , $ errors );
260
261
@@ -334,10 +335,10 @@ public function getAllErrorMessagesDataProvider()
334
335
*/
335
336
public function testResetError ()
336
337
{
337
- AspectMock:: double (
338
- MftfApplicationConfig::class,
339
- [ 'getPhase ' => MftfApplicationConfig:: GENERATION_PHASE ]
340
- );
338
+ $ this -> createMock (MftfApplicationConfig::class)
339
+ -> expects ( $ this -> once ())
340
+ -> method ( 'getPhase ' )
341
+ -> willReturn (MftfApplicationConfig:: GENERATION_PHASE );
341
342
342
343
GenerationErrorHandler::getInstance ()->addError ('something ' , 'some ' , 'error ' );
343
344
GenerationErrorHandler::getInstance ()->addError ('otherthing ' , 'other ' , 'error ' );
@@ -353,7 +354,7 @@ public function testResetError()
353
354
354
355
public function tearDown (): void
355
356
{
356
- $ property = new \ ReflectionProperty (GenerationErrorHandler::class, 'instance ' );
357
+ $ property = new ReflectionProperty (GenerationErrorHandler::class, 'instance ' );
357
358
$ property ->setAccessible (true );
358
359
$ property ->setValue (null );
359
360
}
0 commit comments