Skip to content

Commit ca4f329

Browse files
committed
MQE-1021: Empty Action StepKey Attribute Issues
- Added check for empty stepkey and unit test
1 parent 5dc4c0d commit ca4f329

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ public function testAmbiguousMergeOrderReference()
8989
);
9090
}
9191

92+
/**
93+
* Tests basic action object extraction with an empty stepKey
94+
*/
95+
public function testEmptyStepKey()
96+
{
97+
$this->expectExceptionMessage("StepKeys cannot be empty. Action='sampleAction'");
98+
$this->testActionObjectExtractor->extractActions($this->createBasicActionObjectArray(""));
99+
}
100+
92101
/**
93102
* Utility function to return mock parser output for testing extraction into ActionObjects.
94103
*

src/Magento/FunctionalTestingFramework/Test/Util/ActionObjectExtractor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ActionObjectExtractor extends BaseObjectExtractor
2727
const ACTION_GROUP_ARG_VALUE = 'value';
2828
const BEFORE_AFTER_ERROR_MSG = "Merge Error - Steps cannot have both before and after attributes.\tStepKey='%s'";
2929
const STEP_KEY_BLACKLIST_ERROR_MSG = "StepKeys cannot contain non alphanumeric characters.\tStepKey='%s'";
30+
const STEP_KEY_EMPTY_ERROR_MSG = "StepKeys cannot be empty.\tAction='%s'";
3031
const DATA_PERSISTENCE_CUSTOM_FIELD = 'field';
3132
const DATA_PERSISTENCE_CUSTOM_FIELD_KEY = 'key';
3233
const ACTION_OBJECT_PERSISTENCE_FIELDS = 'customFields';
@@ -59,6 +60,10 @@ public function extractActions($testActions, $testName = null)
5960
foreach ($testActions as $actionName => $actionData) {
6061
$stepKey = $actionData[self::TEST_STEP_MERGE_KEY];
6162

63+
if (empty($stepKey)) {
64+
throw new XmlException(sprintf(self::STEP_KEY_EMPTY_ERROR_MSG, $actionData['nodeName']));
65+
}
66+
6267
if (preg_match('/[^a-zA-Z0-9_]/', $stepKey)) {
6368
throw new XmlException(sprintf(self::STEP_KEY_BLACKLIST_ERROR_MSG, $actionName));
6469
}

0 commit comments

Comments
 (0)