1414use Magento \FunctionalTestingFramework \Util \Script \ScriptUtil ;
1515use Symfony \Component \Finder \SplFileInfo ;
1616use DOMElement ;
17+ use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
18+
1719
1820/**
1921 * Class ActionGroupArgumentsCheck
@@ -24,6 +26,7 @@ class ActionGroupArgumentsCheck implements StaticCheckInterface
2426 const ACTIONGROUP_NAME_REGEX_PATTERN = '/<actionGroup name=[" \']([^ \'"]*)/ ' ;
2527 const ERROR_LOG_FILENAME = 'mftf-arguments-checks ' ;
2628 const ERROR_LOG_MESSAGE = 'MFTF Action Group Unused Arguments Check ' ;
29+ const STEP_KEY_REGEX_PATTERN = '/stepKey=[" \']([^ \'"]*)/ ' ;
2730
2831 /**
2932 * Array containing all errors found after running the execute() function.
@@ -100,6 +103,15 @@ private function findErrorsInFileSet($files)
100103 foreach ($ files as $ filePath ) {
101104 $ actionGroupToArguments = [];
102105 $ contents = $ filePath ->getContents ();
106+ preg_match_all (self ::STEP_KEY_REGEX_PATTERN , $ contents , $ actionGroupReferences );
107+ foreach ($ actionGroupReferences [0 ] as $ actionGroupReferencesData ) {
108+ $ actionGroupReferencesDataArray [] = trim (str_replace (['stepKey ' ,'= ' ],["" ],$ actionGroupReferencesData )).'" ' ;
109+ }
110+ $ duplicateStepKeys = array_unique ( array_diff_assoc ( $ actionGroupReferencesDataArray , array_unique ( $ actionGroupReferencesDataArray ) ) );
111+ unset( $ actionGroupReferencesDataArray );
112+ if (isset ($ duplicateStepKeys ) && count ($ duplicateStepKeys ) > 0 ) {
113+ throw new TestFrameworkException ('Action group has duplicate step keys ' );
114+ }
103115 /** @var DOMElement $actionGroup */
104116 $ actionGroup = $ this ->getActionGroupDomElement ($ contents );
105117 $ arguments = $ this ->extractActionGroupArguments ($ actionGroup );
0 commit comments