Skip to content

Commit f7f9f34

Browse files
Manjusha.SManjusha.S
Manjusha.S
authored and
Manjusha.S
committed
unit test added
1 parent 700e795 commit f7f9f34

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ public function testUniqueIdAppendedToInputStringAsPrefix()
108108
$this->assertMatchesRegularExpression('/[A-Za-z0-9]+foo/', $result);
109109
}
110110

111+
/**
112+
* Basic test to check if exception is thrown when invalid entity is found in xml file
113+
*
114+
* @return void
115+
* @throws Exception
116+
*/
117+
public function testInvalidEntity()
118+
{
119+
$actionObject = new ActionObject('fakeAction', 'comment', [
120+
'userInput' => '{{someEntity.entity}}'
121+
]);
122+
123+
$testObject = new TestObject('sampleTest', ['merge123' => $actionObject], [], [], 'filename');
124+
$testGeneratorObject = TestGenerator::getInstance('', ['sampleTest' => $testObject]);
125+
$this->expectException(TestReferenceException::class);
126+
$result = $testGeneratorObject->entityExistsCheck('testintity', "teststepkey");
127+
}
128+
111129
/**
112130
* Basic test to check unique id is appended to input as suffix
113131
*

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
977977
true
978978
);
979979
$updateEntity = $customActionAttributes['entity'];
980+
$this->entityExistsCheck($updateEntity, $stepKey);
980981
$actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null;
981982
$key .= $actionGroup;
982983

@@ -1010,6 +1011,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
10101011
break;
10111012
case "getData":
10121013
$entity = $customActionAttributes['entity'];
1014+
$this->entityExistsCheck($entity, $stepKey);
10131015
$index = null;
10141016
if (isset($customActionAttributes['index'])) {
10151017
$index = (int)$customActionAttributes['index'];

0 commit comments

Comments
 (0)