Skip to content

Commit 3ae57a6

Browse files
authored
Merge pull request #84 from magento/MQE-782
MQE-782: Fatal error is thrown when a group name conflicts with an existing suite name
2 parents 2e466f2 + 3550ecd commit 3ae57a6

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

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

+15
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function __construct()
4040
* @param array $parsedSuiteData
4141
* @return array
4242
* @throws XmlException
43+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
44+
* @SuppressWarnings(PHPMD.NPathComplexity)
4345
*/
4446
public function parseSuiteDataIntoObjects($parsedSuiteData)
4547
{
@@ -65,6 +67,19 @@ public function parseSuiteDataIntoObjects($parsedSuiteData)
6567

6668
$suiteHooks = [];
6769

70+
//Check for collisions between suite name and existing group name
71+
$suiteName = $parsedSuite[self::NAME];
72+
$testGroupConflicts = TestObjectHandler::getInstance()->getTestsByGroup($suiteName);
73+
if (!empty($testGroupConflicts)) {
74+
$testGroupConflictsFileNames = "";
75+
foreach ($testGroupConflicts as $test) {
76+
$testGroupConflictsFileNames .= $test->getFilename() . "\n";
77+
}
78+
$exceptionmessage = "\"Suite names and Group names can not have the same value. \t\n" .
79+
"Suite: \"{$suiteName}\" also exists as a group annotation in: \n{$testGroupConflictsFileNames}";
80+
throw new XmlException($exceptionmessage);
81+
}
82+
6883
//extract include and exclude references
6984
$groupTestsToInclude = $parsedSuite[self::INCLUDE_TAG_NAME] ?? [];
7085
$groupTestsToExclude = $parsedSuite[self::EXCLUDE_TAG_NAME] ?? [];

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

+20-1
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)