Skip to content

Commit 28fe757

Browse files
committed
MQE-1676: Add a static-check that ensures action groups do not have unused arguments
added exception catch for incorrect action group definition
1 parent 089b88d commit 28fe757

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/commands/mftf.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,15 @@ vendor/bin/mftf static-checks testDependencies
494494
```bash
495495
vendor/bin/mftf static-checks actionGroupArguments
496496
```
497+
```bash
498+
vendor/bin/mftf static-checks testDependencies actionGroupArguments
499+
```
497500

498501
#### Existing static checks
499502

500503
* Test Dependency: Checks that test dependencies do not violate Magento module's composer dependencies.
501-
* Unused Arguments: Checks that action groups do not have unused arguments.
502-
504+
* Action Group Unused Arguments: Checks that action groups do not have unused arguments.
505+
503506
### `upgrade:tests`
504507

505508
Applies all the MFTF major version upgrade scripts to test components in the given path (`test.xml`, `data.xml`, etc).

src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\FunctionalTestingFramework\StaticCheck;
88

99
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
10+
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
1011
use Magento\FunctionalTestingFramework\Test\Handlers\ActionGroupObjectHandler;
1112
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
1213
use Symfony\Component\Console\Input\InputInterface;
@@ -138,9 +139,10 @@ private function findUnusedArguments($actionGroupXml)
138139

139140
preg_match_all(self::ACTIONGROUP_ARGUMENT_REGEX_PATTERN, $actionGroupXml, $arguments);
140141
preg_match(self::ACTIONGROUP_NAME_REGEX_PATTERN, $actionGroupXml, $actionGroupName);
141-
142-
$actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupName[1]);
143-
142+
try {
143+
$actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupName[1]);
144+
} catch (XmlException $e){
145+
}
144146
foreach ($arguments[1] as $argument) {
145147
//pattern to match all argument references
146148
$patterns = [

0 commit comments

Comments
 (0)