Skip to content

Commit 914ebe1

Browse files
committed
MQE-1021: Empty Action StepKey Attribute Issues
- Added filename information for action groups actions as well
1 parent 1099c00 commit 914ebe1

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
7+
8+
use Magento\FunctionalTestingFramework\Test\Util\ActionGroupObjectExtractor;
9+
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
10+
use tests\unit\Util\TestLoggingUtil;
11+
12+
class ActionGroupObjectExtractorTest extends MagentoTestCase
13+
{
14+
/** @var ActionGroupObjectExtractor */
15+
private $testActionGroupObjectExtractor;
16+
17+
/**
18+
* Setup method
19+
*/
20+
public function setUp()
21+
{
22+
$this->testActionGroupObjectExtractor = new ActionGroupObjectExtractor();
23+
TestLoggingUtil::getInstance()->setMockLoggingUtil();
24+
}
25+
26+
/**
27+
* Tests basic action object extraction with an empty stepKey
28+
*/
29+
public function testEmptyStepKey()
30+
{
31+
$this->expectExceptionMessage("StepKeys cannot be empty. Action='sampleAction' in filename.xml");
32+
$this->testActionGroupObjectExtractor->extractActionGroup($this->createBasicActionObjectArray(""));
33+
}
34+
35+
/**
36+
* Utility function to return mock parser output for testing extraction into ActionObjects.
37+
*
38+
* @param string $stepKey
39+
* @param string $actionGroup
40+
* @param string $filename
41+
* @return array
42+
*/
43+
private function createBasicActionObjectArray(
44+
$stepKey = 'testAction1',
45+
$actionGroup = "actionGroup",
46+
$filename = "filename.xml"
47+
) {
48+
$baseArray = [
49+
'nodeName' => 'actionGroup',
50+
'name' => $actionGroup,
51+
'filename' => $filename,
52+
$stepKey => [
53+
"nodeName" => "sampleAction",
54+
"stepKey" => $stepKey,
55+
"someAttribute" => "someAttributeValue"
56+
]
57+
];
58+
return $baseArray;
59+
}
60+
61+
/**
62+
* clean up function runs after all tests
63+
*/
64+
public static function tearDownAfterClass()
65+
{
66+
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
67+
}
68+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ public function extractActionGroup($actionGroupData)
6262
);
6363

6464
// TODO filename is now available to the ActionGroupObject, integrate this into debug and error statements
65-
$actions = $this->actionObjectExtractor->extractActions($actionData);
65+
try {
66+
$actions = $this->actionObjectExtractor->extractActions($actionData);
67+
} catch (\Exception $error) {
68+
throw new XmlException($error->getMessage() . " in " . $actionGroupData[self::FILENAME]);
69+
}
6670

6771
if (array_key_exists(self::ACTION_GROUP_ARGUMENTS, $actionGroupData)) {
6872
$arguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS]);

0 commit comments

Comments
 (0)