3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace tests \unit \Magento \FunctionalTestFramework \Test \Util ;
7
8
8
9
use AspectMock \Proxy \Verifier ;
@@ -31,26 +32,35 @@ public function setUp()
31
32
TestLoggingUtil::getInstance ()->setMockLoggingUtil ();
32
33
}
33
34
35
+ /**
36
+ * After class functionality
37
+ * @return void
38
+ */
39
+ public static function tearDownAfterClass ()
40
+ {
41
+ TestLoggingUtil::getInstance ()->clearMockLoggingUtil ();
42
+ }
43
+
34
44
/**
35
45
* Tests generating a test that extends another test
36
46
* @throws \Exception
37
47
*/
38
48
public function testGenerateExtendedTest ()
39
49
{
40
50
$ mockActions = [
41
- "mockStep " => ["nodeName " => "mockNode " , "stepKey " => "mockStep " ]
51
+ "mockStep " => ["nodeName " => "mockNode " , "stepKey " => "mockStep " ]
42
52
];
43
53
44
54
$ testDataArrayBuilder = new TestDataArrayBuilder ();
45
55
$ mockSimpleTest = $ testDataArrayBuilder
46
56
->withName ('simpleTest ' )
47
- ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
57
+ ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
48
58
->withTestActions ($ mockActions )
49
59
->build ();
50
60
51
61
$ mockExtendedTest = $ testDataArrayBuilder
52
62
->withName ('extendedTest ' )
53
- ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
63
+ ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
54
64
->withTestReference ("simpleTest " )
55
65
->build ();
56
66
@@ -88,14 +98,14 @@ public function testGenerateExtendedWithHooks()
88
98
$ testDataArrayBuilder = new TestDataArrayBuilder ();
89
99
$ mockSimpleTest = $ testDataArrayBuilder
90
100
->withName ('simpleTest ' )
91
- ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
101
+ ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
92
102
->withBeforeHook ($ mockBeforeHooks )
93
103
->withAfterHook ($ mockAfterHooks )
94
104
->build ();
95
105
96
106
$ mockExtendedTest = $ testDataArrayBuilder
97
107
->withName ('extendedTest ' )
98
- ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
108
+ ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
99
109
->withTestReference ("simpleTest " )
100
110
->build ();
101
111
@@ -117,7 +127,7 @@ public function testGenerateExtendedWithHooks()
117
127
$ this ->assertArrayHasKey ("mockStepBefore " , $ testObject ->getHooks ()['before ' ]->getActions ());
118
128
$ this ->assertArrayHasKey ("mockStepAfter " , $ testObject ->getHooks ()['after ' ]->getActions ());
119
129
}
120
-
130
+
121
131
/**
122
132
* Tests generating a test that extends another test
123
133
* @throws \Exception
@@ -158,14 +168,14 @@ public function testExtendingExtendedTest()
158
168
159
169
$ mockSimpleTest = $ testDataArrayBuilder
160
170
->withName ('simpleTest ' )
161
- ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
171
+ ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
162
172
->withTestActions ()
163
173
->withTestReference ("anotherTest " )
164
174
->build ();
165
175
166
176
$ mockExtendedTest = $ testDataArrayBuilder
167
177
->withName ('extendedTest ' )
168
- ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
178
+ ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
169
179
->withTestReference ("simpleTest " )
170
180
->build ();
171
181
@@ -347,7 +357,7 @@ private function setMockTestOutput($testData = null, $actionGroupData = null)
347
357
$ property ->setValue (null );
348
358
349
359
// clear test object handler value to inject parsed content
350
- $ property = new \ReflectionProperty (ActionGroupObjectHandler::class, 'ACTION_GROUP_OBJECT_HANDLER ' );
360
+ $ property = new \ReflectionProperty (ActionGroupObjectHandler::class, 'instance ' );
351
361
$ property ->setAccessible (true );
352
362
$ property ->setValue (null );
353
363
@@ -358,28 +368,21 @@ private function setMockTestOutput($testData = null, $actionGroupData = null)
358
368
)->make ();
359
369
$ instance = AspectMock::double (
360
370
ObjectManager::class,
361
- ['create ' => function ($ clazz ) use (
362
- $ mockDataParser ,
363
- $ mockActionGroupParser
364
- ) {
365
- if ($ clazz == TestDataParser::class) {
366
- return $ mockDataParser ;
371
+ [
372
+ 'create ' => function ($ className ) use (
373
+ $ mockDataParser ,
374
+ $ mockActionGroupParser
375
+ ) {
376
+ if ($ className == TestDataParser::class) {
377
+ return $ mockDataParser ;
378
+ }
379
+ if ($ className == ActionGroupDataParser::class) {
380
+ return $ mockActionGroupParser ;
381
+ }
367
382
}
368
- if ($ clazz == ActionGroupDataParser::class) {
369
- return $ mockActionGroupParser ;
370
- }
371
- }]
383
+ ]
372
384
)->make ();
373
385
// bypass the private constructor
374
386
AspectMock::double (ObjectManagerFactory::class, ['getObjectManager ' => $ instance ]);
375
387
}
376
-
377
- /**
378
- * After class functionality
379
- * @return void
380
- */
381
- public static function tearDownAfterClass ()
382
- {
383
- TestLoggingUtil::getInstance ()->clearMockLoggingUtil ();
384
- }
385
388
}
0 commit comments