|
12 | 12 | use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException;
|
13 | 13 | use Magento\FunctionalTestingFramework\Filter\FilterList;
|
14 | 14 | use Magento\FunctionalTestingFramework\ObjectManager;
|
| 15 | +use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler; |
15 | 16 | use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
|
16 | 17 | use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject;
|
17 | 18 | use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
|
18 | 19 | use Magento\FunctionalTestingFramework\Util\Filesystem\CestFileCreatorUtil;
|
19 | 20 | use Magento\FunctionalTestingFramework\Util\GenerationErrorHandler;
|
20 | 21 | use Magento\FunctionalTestingFramework\Util\ModuleResolver;
|
21 | 22 | use Magento\FunctionalTestingFramework\Util\TestGenerator;
|
| 23 | +use ReflectionClass; |
22 | 24 | use ReflectionProperty;
|
23 | 25 | use tests\unit\Util\MagentoTestCase;
|
24 | 26 | use tests\unit\Util\TestLoggingUtil;
|
@@ -75,6 +77,8 @@ public function testEntityException(): void
|
75 | 77 |
|
76 | 78 | $testObject = new TestObject('sampleTest', ['merge123' => $actionObject], [], [], 'filename');
|
77 | 79 | $testGeneratorObject = TestGenerator::getInstance('', ['sampleTest' => $testObject]);
|
| 80 | + $this->mockTestObjectHandler(); |
| 81 | + |
78 | 82 | $testGeneratorObject->createAllTestFiles(null, []);
|
79 | 83 |
|
80 | 84 | // assert that no exception for createAllTestFiles and generation error is stored in GenerationErrorHandler
|
@@ -231,5 +235,25 @@ public static function tearDownAfterClass(): void
|
231 | 235 | $mftfAppConfigInstance = new ReflectionProperty(MftfApplicationConfig::class, 'MFTF_APPLICATION_CONTEXT');
|
232 | 236 | $mftfAppConfigInstance->setAccessible(true);
|
233 | 237 | $mftfAppConfigInstance->setValue(null);
|
| 238 | + |
| 239 | + $property = new ReflectionProperty(TestObjectHandler::class, 'testObjectHandler'); |
| 240 | + $property->setAccessible(true); |
| 241 | + $property->setValue(null); |
| 242 | + } |
| 243 | + |
| 244 | + /** |
| 245 | + * Mock test object handler for test. |
| 246 | + */ |
| 247 | + private function mockTestObjectHandler(): void |
| 248 | + { |
| 249 | + $testObjectHandlerClass = new ReflectionClass(TestObjectHandler::class); |
| 250 | + $testObjectHandlerConstructor = $testObjectHandlerClass->getConstructor(); |
| 251 | + $testObjectHandlerConstructor->setAccessible(true); |
| 252 | + $testObjectHandler = $testObjectHandlerClass->newInstanceWithoutConstructor(); |
| 253 | + $testObjectHandlerConstructor->invoke($testObjectHandler); |
| 254 | + |
| 255 | + $property = new ReflectionProperty(TestObjectHandler::class, 'testObjectHandler'); |
| 256 | + $property->setAccessible(true); |
| 257 | + $property->setValue($testObjectHandler); |
234 | 258 | }
|
235 | 259 | }
|
0 commit comments