Skip to content

Commit 11d1f04

Browse files
Manjusha.SManjusha.S
Manjusha.S
authored and
Manjusha.S
committed
throw exception
1 parent 665b114 commit 11d1f04

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Magento\FunctionalTestingFramework\Util\Script\ScriptUtil;
1515
use Symfony\Component\Finder\SplFileInfo;
1616
use 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

Comments
 (0)