Skip to content

Commit c6a8ef9

Browse files
committed
MQE-782: Fatal error is thrown when a group name conflicts with an existing suite name
- Added getter for $filename to TestObject - Added check for matching suite and groups names to SuiteObjectExtractor MQE-782: Fatal error is thrown when a group name conflicts with an existing suite name - Fixed static check failures on line length MQE-782: Fatal error is thrown when a group name conflicts with an existing suite name - Modified exception message formatting for more readable output MQE-782: Fatal error is thrown when a group name conflicts with an existing suite name - Suppress Warnings for Cyclomatic and NPath SuiteObjectExtractor::parseSuiteDataIntoObjects
1 parent cfb142b commit c6a8ef9

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/Magento/FunctionalTestingFramework/Suite/Util/SuiteObjectExtractor.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function __construct()
3939
* @param array $parsedSuiteData
4040
* @return array
4141
* @throws XmlException
42+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
43+
* @SuppressWarnings(PHPMD.NPathComplexity)
4244
*/
4345
public function parseSuiteDataIntoObjects($parsedSuiteData)
4446
{
@@ -55,6 +57,19 @@ public function parseSuiteDataIntoObjects($parsedSuiteData)
5557

5658
$suiteHooks = [];
5759

60+
//Check for collisions between suite name and existing group name
61+
$suiteName = $parsedSuite[self::NAME];
62+
$testGroupConflicts = TestObjectHandler::getInstance()->getTestsByGroup($suiteName);
63+
if (!empty($testGroupConflicts)) {
64+
$testGroupConflictsFileNames = "";
65+
foreach ($testGroupConflicts as $test) {
66+
$testGroupConflictsFileNames .= $test->getFilename() . "\n";
67+
}
68+
$exceptionmessage = "\"Suite names and Group names can not have the same value. \t\n" .
69+
"Suite: \"{$suiteName}\" also exists as a group annotation in: \n{$testGroupConflictsFileNames}";
70+
throw new XmlException($exceptionmessage);
71+
}
72+
5873
//extract include and exclude references
5974
$groupTestsToInclude = $parsedSuite[self::INCLUDE_TAG_NAME] ?? [];
6075
$groupTestsToExclude = $parsedSuite[self::EXCLUDE_TAG_NAME] ?? [];

src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,29 @@ class TestObject
4343
*/
4444
private $hooks = [];
4545

46+
/**
47+
* String of filename of test
48+
*
49+
* @var String
50+
*/
51+
private $filename;
52+
4653
/**
4754
* TestObject constructor.
4855
*
4956
* @param string $name
5057
* @param ActionObject[] $parsedSteps
5158
* @param array $annotations
5259
* @param TestHookObject[] $hooks
60+
* @param String $filename
5361
*/
54-
public function __construct($name, $parsedSteps, $annotations, $hooks)
62+
public function __construct($name, $parsedSteps, $annotations, $hooks, $filename = null)
5563
{
5664
$this->name = $name;
5765
$this->parsedSteps = $parsedSteps;
5866
$this->annotations = $annotations;
5967
$this->hooks = $hooks;
68+
$this->filename = $filename;
6069
}
6170

6271
/**
@@ -69,6 +78,16 @@ public function getName()
6978
return $this->name;
7079
}
7180

81+
/**
82+
* Getter for the Test Filename
83+
*
84+
* @return string
85+
*/
86+
public function getFilename()
87+
{
88+
return $this->filename;
89+
}
90+
7291
/**
7392
* Getter for Codeception format name
7493
*

0 commit comments

Comments
 (0)