Skip to content

Commit 8f632fd

Browse files
authored
MQE-395: Throw an exception when a test references an actionGroup that doesn't exist
- Throwing testReferenceException if actionGroup returned is null.
1 parent 0f22e60 commit 8f632fd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ private function __construct()
6666
*/
6767
public function getObject($actionGroupName)
6868
{
69-
return $this->getAllObjects()[$actionGroupName];
69+
if (array_key_exists($actionGroupName, $this->getAllObjects())) {
70+
return $this->getAllObjects()[$actionGroupName];
71+
}
72+
73+
return null;
7074
}
7175

7276
/**

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\FunctionalTestingFramework\Test\Util;
88

9+
use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException;
910
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
1011
use Magento\FunctionalTestingFramework\Test\Handlers\ActionGroupObjectHandler;
1112
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
@@ -69,6 +70,7 @@ public function resolveActionSteps($parsedSteps, $skipActionGroupResolution = fa
6970
* Method to resolve action group references and insert relevant actions into step flow
7071
*
7172
* @param array $mergedSteps
73+
* @throws TestReferenceException
7274
* @return array
7375
*/
7476
private function resolveActionGroups($mergedSteps)
@@ -78,9 +80,11 @@ private function resolveActionGroups($mergedSteps)
7880
foreach ($mergedSteps as $key => $mergedStep) {
7981
/**@var ActionObject $mergedStep**/
8082
if ($mergedStep->getType() == ActionObjectExtractor::ACTION_GROUP_TAG) {
81-
$actionGroup = ActionGroupObjectHandler::getInstance()->getObject(
82-
$mergedStep->getCustomActionAttributes()[ActionObjectExtractor::ACTION_GROUP_REF]
83-
);
83+
$actionGroupRef = $mergedStep->getCustomActionAttributes()[ActionObjectExtractor::ACTION_GROUP_REF];
84+
$actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupRef);
85+
if ($actionGroup == null) {
86+
throw new TestReferenceException("Could not find ActionGroup by ref \"{$actionGroupRef}\"");
87+
}
8488
$args = $mergedStep->getCustomActionAttributes()[ActionObjectExtractor::ACTION_GROUP_ARGUMENTS] ?? null;
8589
$actionsToMerge = $actionGroup->getSteps($args, $key);
8690
$newOrderedList = $newOrderedList + $actionsToMerge;

0 commit comments

Comments
 (0)