23 private $storyToTitleMappings = [];
28 private $testCaseToTitleMappings = [];
32 "BLOCKER" =>
"BLOCKER",
33 "CRITICAL" =>
"CRITICAL",
64 $annotationObjects = [];
69 foreach ($annotations as $annotationKey => $annotationData) {
70 $annotationValues = [];
72 if ($annotationKey ==
"severity") {
74 $annotationData[0][
'value']
79 if ($annotationKey ==
"skip") {
80 $annotationData = $annotationData[
'issueId'];
84 foreach ($annotationData as $annotationValue) {
88 if ($annotationKey ==
"group" && in_array(
"skip", $annotationValues)) {
90 "Use of group skip will be deprecated in MFTF 3.0.0. Please update tests to use skip tags.",
95 $annotationObjects[$annotationKey] = $annotationValues;
98 $this->addTestCaseIdToTitle($annotationObjects, $filename);
99 $this->validateMissingAnnotations($annotationObjects, $filename);
102 return $annotationObjects;
113 if (isset($annotations[
'stories']) && isset($annotations[
'title'])) {
114 $story = $annotations[
'stories'][0];
115 $title = $annotations[
'title'][0];
116 $this->storyToTitleMappings[$story .
"/" .
$title][] = $filename;
126 private function addTestCaseIdToTitle(&$annotations, $filename)
128 if (!isset($annotations[
'title'])) {
132 $testCaseId =
"[NO TESTCASEID]";
134 if (isset($annotations[
'testCaseId'])) {
135 $testCaseId = $annotations[
'testCaseId'][0];
138 $newTitle =
"{$testCaseId}: " . $annotations[
'title'][0];
140 $annotations[
'title'][0] = $newTitle;
141 $this->testCaseToTitleMappings[$newTitle][] = $filename;
149 private function validateMissingAnnotations($annotationObjects, $filename)
151 $missingAnnotations = [];
153 foreach (self::REQUIRED_ANNOTATIONS as $REQUIRED_ANNOTATION) {
154 if (!array_key_exists($REQUIRED_ANNOTATION, $annotationObjects)) {
155 $missingAnnotations[] = $REQUIRED_ANNOTATION;
159 if (!empty($missingAnnotations)) {
160 $message =
"Test {$filename} is missing required annotations.";
163 [
"testName" => $filename,
"missingAnnotations" => implode(
", ", $missingAnnotations)]
177 foreach ($this->storyToTitleMappings as $storyTitle =>
$files) {
179 $dupes[$storyTitle] =
"'" . implode(
"', '",
$files) .
"'";
182 if (!empty($dupes)) {
183 $message =
"Story and Title annotation pairs must be unique:\n\n";
184 foreach ($dupes as $storyTitle => $tests) {
185 $storyTitleArray = explode(
"/", $storyTitle);
186 $story = $storyTitleArray[0];
187 $title = $storyTitleArray[1];
188 $message .=
"Story: '{$story}' Title: '{$title}' in Tests {$tests}\n\n";
203 foreach ($this->testCaseToTitleMappings as $newTitle =>
$files) {
205 $dupes[$newTitle] =
"'" . implode(
"', '",
$files) .
"'";
208 if (!empty($dupes)) {
209 $message =
"TestCaseId and Title pairs must be unique:\n\n";
210 foreach ($dupes as $newTitle => $tests) {
211 $testCaseTitleArray = explode(
": ", $newTitle);
212 $testCaseId = $testCaseTitleArray[0];
213 $title = $testCaseTitleArray[1];
214 $message .=
"TestCaseId: '{$testCaseId}' Title: '{$title}' in Tests {$tests}\n\n";
229 foreach ($issues as $issueId) {
230 if (empty($issueId[
'value'])) {
231 $message =
"issueId for skipped tests cannot be empty. Test: $filename";
246 $annotationValue = strtoupper($annotationData);
250 $allureAnnotation[] = self::MAGENTO_TO_ALLURE_SEVERITY_MAP[$annotationValue] ?? $annotationValue;
252 return $allureAnnotation;
foreach($appDirs as $dir) $files