Skip to content

Commit b2b628c

Browse files
authored
Merge pull request #90 from magento-commerce/imported-magento-magento2-functional-testing-framework-844
[Imported] MFTF-33301: Eliminated AspectMock usage for TestObjectHandlerTest
2 parents 66a652b + 7033c7f commit b2b628c

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php

+39-31
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,43 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace tests\unit\Magento\FunctionalTestFramework\Test\Handlers;
89

9-
use AspectMock\Test as AspectMock;
10-
11-
use Magento\FunctionalTestingFramework\ObjectManager;
12-
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
10+
use Exception;
1311
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
1412
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1513
use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject;
1614
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
17-
use Magento\FunctionalTestingFramework\Test\Parsers\TestDataParser;
1815
use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor;
16+
use Magento\FunctionalTestingFramework\Util\GenerationErrorHandler;
1917
use tests\unit\Util\MagentoTestCase;
18+
use tests\unit\Util\MockModuleResolverBuilder;
2019
use tests\unit\Util\ObjectHandlerUtil;
2120
use tests\unit\Util\TestDataArrayBuilder;
22-
use tests\unit\Util\MockModuleResolverBuilder;
2321
use tests\unit\Util\TestLoggingUtil;
24-
use Magento\FunctionalTestingFramework\Util\GenerationErrorHandler;
2522

2623
class TestObjectHandlerTest extends MagentoTestCase
2724
{
28-
public function setUp(): void
25+
/**
26+
* Before test functionality.
27+
*
28+
* @return void
29+
* @throws Exception
30+
*/
31+
protected function setUp(): void
2932
{
3033
TestLoggingUtil::getInstance()->setMockLoggingUtil();
3134
}
3235

3336
/**
3437
* Basic test to validate array => test object conversion.
3538
*
36-
* @throws \Exception
39+
* @return void
40+
* @throws Exception
3741
*/
38-
public function testGetTestObject()
42+
public function testGetTestObject(): void
3943
{
4044
// set up mock data
4145
$testDataArrayBuilder = new TestDataArrayBuilder();
@@ -53,7 +57,6 @@ public function testGetTestObject()
5357

5458
// run object handler method
5559
$toh = TestObjectHandler::getInstance();
56-
$mockConfig = AspectMock::double(TestObjectHandler::class, ['initTestData' => false]);
5760
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);
5861

5962
// perform asserts
@@ -114,19 +117,22 @@ public function testGetTestObject()
114117
}
115118

116119
/**
117-
* Tests basic getting of a test that has a fileName
120+
* Tests basic getting of a test that has a fileName.
121+
*
122+
* @return void
118123
*/
119-
public function testGetTestWithFileName()
124+
public function testGetTestWithFileName(): void
120125
{
121126
$this->markTestIncomplete('TODO');
122127
}
123128

124129
/**
125130
* Tests the function used to get a series of relevant tests by group.
126131
*
127-
* @throws \Exception
132+
* @return void
133+
* @throws Exception
128134
*/
129-
public function testGetTestsByGroup()
135+
public function testGetTestsByGroup(): void
130136
{
131137
// set up mock data with Exclude Test
132138
$includeTest = (new TestDataArrayBuilder())
@@ -155,11 +161,12 @@ public function testGetTestsByGroup()
155161
}
156162

157163
/**
158-
* Tests the function used to parse and determine a test's Module (used in allure Features annotation)
164+
* Tests the function used to parse and determine a test's Module (used in allure Features annotation).
159165
*
160-
* @throws \Exception
166+
* @return void
167+
* @throws Exception
161168
*/
162-
public function testGetTestWithModuleName()
169+
public function testGetTestWithModuleName(): void
163170
{
164171
// set up Test Data
165172
$moduleExpected = "SomeModuleName";
@@ -201,11 +208,12 @@ public function testGetTestWithModuleName()
201208
}
202209

203210
/**
204-
* getObject should throw exception if test extends from itself
211+
* getObject should throw exception if test extends from itself.
205212
*
206-
* @throws \Exception
213+
* @return void
214+
* @throws Exception
207215
*/
208-
public function testGetTestObjectWithInvalidExtends()
216+
public function testGetTestObjectWithInvalidExtends(): void
209217
{
210218
// set up Test Data
211219
$testOne = (new TestDataArrayBuilder())
@@ -230,11 +238,12 @@ public function testGetTestObjectWithInvalidExtends()
230238
}
231239

232240
/**
233-
* getAllObjects should throw exception if test extends from itself
241+
* getAllObjects should throw exception if test extends from itself.
234242
*
235-
* @throws \Exception
243+
* @return void
244+
* @throws Exception
236245
*/
237-
public function testGetAllTestObjectsWithInvalidExtends()
246+
public function testGetAllTestObjectsWithInvalidExtends(): void
238247
{
239248
// set up Test Data
240249
$testOne = (new TestDataArrayBuilder())
@@ -270,11 +279,12 @@ public function testGetAllTestObjectsWithInvalidExtends()
270279
}
271280

272281
/**
273-
* Validate test object when ENABLE_PAUSE is set to true
282+
* Validate test object when ENABLE_PAUSE is set to true.
274283
*
275-
* @throws \Exception
284+
* @return void
285+
* @throws Exception
276286
*/
277-
public function testGetTestObjectWhenEnablePause()
287+
public function testGetTestObjectWhenEnablePause(): void
278288
{
279289
// set up mock data
280290
putenv('ENABLE_PAUSE=true');
@@ -293,7 +303,6 @@ public function testGetTestObjectWhenEnablePause()
293303

294304
// run object handler method
295305
$toh = TestObjectHandler::getInstance();
296-
$mockConfig = AspectMock::double(TestObjectHandler::class, ['initTestData' => false]);
297306
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);
298307

299308
// perform asserts
@@ -363,14 +372,13 @@ public function testGetTestObjectWhenEnablePause()
363372
}
364373

365374
/**
366-
* After method functionality
375+
* After method functionality.
367376
*
368377
* @return void
369378
*/
370-
public function tearDown(): void
379+
protected function tearDown(): void
371380
{
372381
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
373-
AspectMock::clean();
374382
parent::tearDownAfterClass();
375383
}
376384
}

0 commit comments

Comments
 (0)