Skip to content

Commit 198aeaa

Browse files
committed
Fix PHPUnit errors
1 parent 5193f1e commit 198aeaa

File tree

5 files changed

+40
-37
lines changed

5 files changed

+40
-37
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function setMockTestAndSuiteParserOutput($testData, $suiteData)
8585
$property->setValue(null);
8686

8787
// clear suite object handler value to inject parsed content
88-
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'SUITE_OBJECT_HANLDER_INSTANCE');
88+
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'instance');
8989
$property->setAccessible(true);
9090
$property->setValue(null);
9191

dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function testGenerateEmptySuite()
149149
*/
150150
private function setMockTestAndSuiteParserOutput($testData, $suiteData)
151151
{
152-
$property = new \ReflectionProperty(SuiteGenerator::class, 'SUITE_GENERATOR_INSTANCE');
152+
$property = new \ReflectionProperty(SuiteGenerator::class, 'instance');
153153
$property->setAccessible(true);
154154
$property->setValue(null);
155155

@@ -159,7 +159,7 @@ private function setMockTestAndSuiteParserOutput($testData, $suiteData)
159159
$property->setValue(null);
160160

161161
// clear suite object handler value to inject parsed content
162-
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'SUITE_OBJECT_HANLDER_INSTANCE');
162+
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'instance');
163163
$property->setAccessible(true);
164164
$property->setValue(null);
165165

dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
78

89
use 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
}

dev/tests/unit/Util/TestLoggingUtil.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestLoggingUtil extends Assert
1818
/**
1919
* @var TestLoggingUtil
2020
*/
21-
private static $INSTANCE;
21+
private static $instance;
2222

2323
/**
2424
* @var TestHandler
@@ -40,11 +40,11 @@ private function __construct()
4040
*/
4141
public static function getInstance()
4242
{
43-
if (self::$INSTANCE == null) {
44-
self::$INSTANCE = new TestLoggingUtil();
43+
if (self::$instance == null) {
44+
self::$instance = new TestLoggingUtil();
4545
}
4646

47-
return self::$INSTANCE;
47+
return self::$instance;
4848
}
4949

5050
/**
@@ -61,7 +61,7 @@ public function setMockLoggingUtil()
6161
LoggingUtil::class,
6262
['getLogger' => $testLogger]
6363
)->make();
64-
$property = new \ReflectionProperty(LoggingUtil::class, 'INSTANCE');
64+
$property = new \ReflectionProperty(LoggingUtil::class, 'instance');
6565
$property->setAccessible(true);
6666
$property->setValue($mockLoggingUtil);
6767
}

src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function __construct()
7272
* @param string $actionGroupName
7373
* @return ActionGroupObject
7474
*/
75-
public function getObject($actionGroupName): ActionGroupObject
75+
public function getObject($actionGroupName)
7676
{
7777
if (array_key_exists($actionGroupName, $this->actionGroups)) {
7878
$actionGroupObject = $this->actionGroups[$actionGroupName];

0 commit comments

Comments
 (0)