14
14
use Magento \FunctionalTestingFramework \Util \Script \ScriptUtil ;
15
15
use Symfony \Component \Finder \SplFileInfo ;
16
16
use DOMElement ;
17
+ use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
18
+
17
19
18
20
/**
19
21
* Class ActionGroupArgumentsCheck
@@ -24,6 +26,7 @@ class ActionGroupArgumentsCheck implements StaticCheckInterface
24
26
const ACTIONGROUP_NAME_REGEX_PATTERN = '/<actionGroup name=[" \']([^ \'"]*)/ ' ;
25
27
const ERROR_LOG_FILENAME = 'mftf-arguments-checks ' ;
26
28
const ERROR_LOG_MESSAGE = 'MFTF Action Group Unused Arguments Check ' ;
29
+ const STEP_KEY_REGEX_PATTERN = '/stepKey=[" \']([^ \'"]*)/ ' ;
27
30
28
31
/**
29
32
* Array containing all errors found after running the execute() function.
@@ -100,6 +103,15 @@ private function findErrorsInFileSet($files)
100
103
foreach ($ files as $ filePath ) {
101
104
$ actionGroupToArguments = [];
102
105
$ 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
+ }
103
115
/** @var DOMElement $actionGroup */
104
116
$ actionGroup = $ this ->getActionGroupDomElement ($ contents );
105
117
$ arguments = $ this ->extractActionGroupArguments ($ actionGroup );
0 commit comments