Skip to content

Commit 1075fd4

Browse files
committed
MQE-1513: createData throws a useless error message during runtime when the entity does not exist
1 parent 4e1ea0a commit 1075fd4

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ public function testEntityException()
4242
$testGeneratorObject->createAllTestFiles(null, []);
4343
}
4444

45-
/**
46-
* Test to check exceptions for createData on referencing non-existent entity
47-
*
48-
* @throws TestReferenceException
49-
*/
50-
51-
public function testCreateDataException()
52-
{
53-
$actionObject = new ActionObject('fakeAction', 'createData', [
54-
'entity' => 'invalidEntity'
55-
]);
56-
57-
$testObject = new TestObject("sampleTest", ["merge123" => $actionObject], [], [], "filename");
58-
59-
$testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]);
60-
61-
AspectMock::double(TestGenerator::class, ['loadAllTestObjects' => ["sampleTest" => $testObject]]);
62-
63-
$this->expectExceptionMessage("Entity \"invalidEntity\" does not exist." .
64-
"\nException occurred parsing action at StepKey \"fakeAction\" in Test \"sampleTest\"");
65-
66-
$testGeneratorObject->createAllTestFiles(null, []);
67-
}
68-
6945
/**
7046
* Tests that skipped tests do not have a fully generated body
7147
*

src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ public function createEntity(
9797
}
9898

9999
$retrievedEntity = DataObjectHandler::getInstance()->getObject($entity);
100+
101+
if ($retrievedEntity === null) {
102+
throw new TestReferenceException(
103+
"Entity \"" . $entity . "\" does not exist." .
104+
"\nException occurred parsing action at StepKey \"" . $key . "\""
105+
);
106+
}
107+
100108
$persistedObject = new DataPersistenceHandler(
101109
$retrievedEntity,
102110
$retrievedDependentObjects,

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
731731
case "createData":
732732
$entity = $customActionAttributes['entity'];
733733

734-
if(DataObjectHandler::getInstance()->getObject($entity) === null) {
735-
throw new TestReferenceException(
736-
"Entity \"" . $entity . "\" does not exist." .
737-
"\nException occurred parsing action at StepKey \"" . $stepKey . "\""
738-
);
739-
}
740-
741734
//TODO refactor entity field override to not be individual actionObjects
742735
$customEntityFields =
743736
$customActionAttributes[ActionObjectExtractor::ACTION_OBJECT_PERSISTENCE_FIELDS] ?? [];

0 commit comments

Comments
 (0)