33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+
67namespace tests \unit \Magento \FunctionalTestFramework \Test \Util ;
78
89use AspectMock \Proxy \Verifier ;
@@ -31,26 +32,35 @@ public function setUp()
3132 TestLoggingUtil::getInstance ()->setMockLoggingUtil ();
3233 }
3334
35+ /**
36+ * After class functionality
37+ * @return void
38+ */
39+ public static function tearDownAfterClass ()
40+ {
41+ TestLoggingUtil::getInstance ()->clearMockLoggingUtil ();
42+ }
43+
3444 /**
3545 * Tests generating a test that extends another test
3646 * @throws \Exception
3747 */
3848 public function testGenerateExtendedTest ()
3949 {
4050 $ mockActions = [
41- "mockStep " => ["nodeName " => "mockNode " , "stepKey " => "mockStep " ]
51+ "mockStep " => ["nodeName " => "mockNode " , "stepKey " => "mockStep " ]
4252 ];
4353
4454 $ testDataArrayBuilder = new TestDataArrayBuilder ();
4555 $ mockSimpleTest = $ testDataArrayBuilder
4656 ->withName ('simpleTest ' )
47- ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
57+ ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
4858 ->withTestActions ($ mockActions )
4959 ->build ();
5060
5161 $ mockExtendedTest = $ testDataArrayBuilder
5262 ->withName ('extendedTest ' )
53- ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
63+ ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
5464 ->withTestReference ("simpleTest " )
5565 ->build ();
5666
@@ -88,14 +98,14 @@ public function testGenerateExtendedWithHooks()
8898 $ testDataArrayBuilder = new TestDataArrayBuilder ();
8999 $ mockSimpleTest = $ testDataArrayBuilder
90100 ->withName ('simpleTest ' )
91- ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
101+ ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
92102 ->withBeforeHook ($ mockBeforeHooks )
93103 ->withAfterHook ($ mockAfterHooks )
94104 ->build ();
95105
96106 $ mockExtendedTest = $ testDataArrayBuilder
97107 ->withName ('extendedTest ' )
98- ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
108+ ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
99109 ->withTestReference ("simpleTest " )
100110 ->build ();
101111
@@ -117,7 +127,7 @@ public function testGenerateExtendedWithHooks()
117127 $ this ->assertArrayHasKey ("mockStepBefore " , $ testObject ->getHooks ()['before ' ]->getActions ());
118128 $ this ->assertArrayHasKey ("mockStepAfter " , $ testObject ->getHooks ()['after ' ]->getActions ());
119129 }
120-
130+
121131 /**
122132 * Tests generating a test that extends another test
123133 * @throws \Exception
@@ -158,14 +168,14 @@ public function testExtendingExtendedTest()
158168
159169 $ mockSimpleTest = $ testDataArrayBuilder
160170 ->withName ('simpleTest ' )
161- ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
171+ ->withAnnotations (['title ' => [['value ' => 'simpleTest ' ]]])
162172 ->withTestActions ()
163173 ->withTestReference ("anotherTest " )
164174 ->build ();
165175
166176 $ mockExtendedTest = $ testDataArrayBuilder
167177 ->withName ('extendedTest ' )
168- ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
178+ ->withAnnotations (['title ' => [['value ' => 'extendedTest ' ]]])
169179 ->withTestReference ("simpleTest " )
170180 ->build ();
171181
@@ -347,7 +357,7 @@ private function setMockTestOutput($testData = null, $actionGroupData = null)
347357 $ property ->setValue (null );
348358
349359 // 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 ' );
351361 $ property ->setAccessible (true );
352362 $ property ->setValue (null );
353363
@@ -358,28 +368,21 @@ private function setMockTestOutput($testData = null, $actionGroupData = null)
358368 )->make ();
359369 $ instance = AspectMock::double (
360370 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+ }
367382 }
368- if ($ clazz == ActionGroupDataParser::class) {
369- return $ mockActionGroupParser ;
370- }
371- }]
383+ ]
372384 )->make ();
373385 // bypass the private constructor
374386 AspectMock::double (ObjectManagerFactory::class, ['getObjectManager ' => $ instance ]);
375387 }
376-
377- /**
378- * After class functionality
379- * @return void
380- */
381- public static function tearDownAfterClass ()
382- {
383- TestLoggingUtil::getInstance ()->clearMockLoggingUtil ();
384- }
385388}
0 commit comments