Skip to content

Commit 3c0dcdd

Browse files
committed
33299: Fixed static-test
1 parent c6025c4 commit 3c0dcdd

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

src/Magento/FunctionalTestingFramework/Suite/Service/SuiteGeneratorService.php

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\FunctionalTestingFramework\Suite\Service;
99

1010
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
11+
use Magento\FunctionalTestingFramework\Suite\SuiteGenerator;
1112
use Magento\FunctionalTestingFramework\Util\Path\FilePathFormatter;
1213
use Symfony\Component\Yaml\Yaml;
1314

@@ -16,15 +17,6 @@
1617
*/
1718
class SuiteGeneratorService
1819
{
19-
const YAML_CODECEPTION_DIST_FILENAME = 'codeception.dist.yml';
20-
const YAML_CODECEPTION_CONFIG_FILENAME = 'codeception.yml';
21-
const YAML_GROUPS_TAG = 'groups';
22-
const YAML_EXTENSIONS_TAG = 'extensions';
23-
const YAML_ENABLED_TAG = 'enabled';
24-
const YAML_COPYRIGHT_TEXT =
25-
"# Copyright © Magento, Inc. All rights reserved.\n# See COPYING.txt for license details.\n";
26-
27-
2820
/**
2921
* Singleton SuiteGeneratorService Instance.
3022
*
@@ -65,56 +57,57 @@ public function clearPreviousSessionConfigEntries()
6557
$ymlArray = self::getYamlFileContents();
6658
$newYmlArray = $ymlArray;
6759
// if the yaml entries haven't already been cleared
68-
if (array_key_exists(self::YAML_EXTENSIONS_TAG, $ymlArray)) {
69-
foreach ($ymlArray[self::YAML_EXTENSIONS_TAG][self::YAML_ENABLED_TAG] as $key => $entry) {
60+
if (array_key_exists(SuiteGenerator::YAML_EXTENSIONS_TAG, $ymlArray)) {
61+
$ymlEntries = $ymlArray[SuiteGenerator::YAML_EXTENSIONS_TAG][SuiteGenerator::YAML_ENABLED_TAG];
62+
63+
foreach ($ymlEntries as $key => $entry) {
7064
if (preg_match('/(Group\\\\.*)/', $entry)) {
71-
unset($newYmlArray[self::YAML_EXTENSIONS_TAG][self::YAML_ENABLED_TAG][$key]);
65+
unset($newYmlArray[SuiteGenerator::YAML_EXTENSIONS_TAG][SuiteGenerator::YAML_ENABLED_TAG][$key]);
7266
}
7367
}
7468

7569
// needed for proper yml file generation based on indices
76-
$newYmlArray[self::YAML_EXTENSIONS_TAG][self::YAML_ENABLED_TAG] =
77-
array_values($newYmlArray[self::YAML_EXTENSIONS_TAG][self::YAML_ENABLED_TAG]);
70+
$newYmlArray[SuiteGenerator::YAML_EXTENSIONS_TAG][SuiteGenerator::YAML_ENABLED_TAG] =
71+
array_values($newYmlArray[SuiteGenerator::YAML_EXTENSIONS_TAG][SuiteGenerator::YAML_ENABLED_TAG]);
7872
}
7973

80-
if (array_key_exists(self::YAML_GROUPS_TAG, $newYmlArray)) {
81-
unset($newYmlArray[self::YAML_GROUPS_TAG]);
74+
if (array_key_exists(SuiteGenerator::YAML_GROUPS_TAG, $newYmlArray)) {
75+
unset($newYmlArray[SuiteGenerator::YAML_GROUPS_TAG]);
8276
}
8377

84-
$ymlText = self::YAML_COPYRIGHT_TEXT . Yaml::dump($newYmlArray, 10);
85-
file_put_contents(self::getYamlConfigFilePath() . self::YAML_CODECEPTION_CONFIG_FILENAME, $ymlText);
78+
$ymlText = SuiteGenerator::YAML_COPYRIGHT_TEXT . Yaml::dump($newYmlArray, 10);
79+
file_put_contents(self::getYamlConfigFilePath() . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME, $ymlText);
8680
}
8781

88-
8982
/**
9083
* Function which accepts a suite name and suite path and appends a new group entry to the codeception.yml.dist
9184
* file in order to register the set of tests as a new group. Also appends group object location if required
9285
* by suite.
9386
*
94-
* @param string $suiteName
95-
* @param string $suitePath
96-
* @param string $groupNamespace
87+
* @param string $suiteName
88+
* @param string $suitePath
89+
* @param string|null $groupNamespace
9790
*
9891
* @return void
9992
* @throws TestFrameworkException
10093
*/
101-
public function appendEntriesToConfig(string $suiteName, string $suitePath, string $groupNamespace)
94+
public function appendEntriesToConfig(string $suiteName, string $suitePath, ?string $groupNamespace)
10295
{
10396
$relativeSuitePath = substr($suitePath, strlen(TESTS_BP));
10497
$relativeSuitePath = ltrim($relativeSuitePath, DIRECTORY_SEPARATOR);
10598
$ymlArray = self::getYamlFileContents();
10699

107-
if (!array_key_exists(self::YAML_GROUPS_TAG, $ymlArray)) {
108-
$ymlArray[self::YAML_GROUPS_TAG]= [];
100+
if (!array_key_exists(SuiteGenerator::YAML_GROUPS_TAG, $ymlArray)) {
101+
$ymlArray[SuiteGenerator::YAML_GROUPS_TAG] = [];
109102
}
110103

111104
if ($groupNamespace) {
112-
$ymlArray[self::YAML_EXTENSIONS_TAG][self::YAML_ENABLED_TAG][] = $groupNamespace;
105+
$ymlArray[SuiteGenerator::YAML_EXTENSIONS_TAG][SuiteGenerator::YAML_ENABLED_TAG][] = $groupNamespace;
113106
}
114107

115-
$ymlArray[self::YAML_GROUPS_TAG][$suiteName] = [$relativeSuitePath];
116-
$ymlText = self::YAML_COPYRIGHT_TEXT . Yaml::dump($ymlArray, 10);
117-
file_put_contents(self::getYamlConfigFilePath() . self::YAML_CODECEPTION_CONFIG_FILENAME, $ymlText);
108+
$ymlArray[SuiteGenerator::YAML_GROUPS_TAG][$suiteName] = [$relativeSuitePath];
109+
$ymlText = SuiteGenerator::YAML_COPYRIGHT_TEXT . Yaml::dump($ymlArray, 10);
110+
file_put_contents(self::getYamlConfigFilePath() . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME, $ymlText);
118111
}
119112

120113
/**
@@ -125,8 +118,8 @@ public function appendEntriesToConfig(string $suiteName, string $suitePath, stri
125118
*/
126119
private static function getYamlFileContents(): array
127120
{
128-
$configYmlFile = self::getYamlConfigFilePath() . self::YAML_CODECEPTION_CONFIG_FILENAME;
129-
$defaultConfigYmlFile = self::getYamlConfigFilePath() . self::YAML_CODECEPTION_DIST_FILENAME;
121+
$configYmlFile = self::getYamlConfigFilePath() . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME;
122+
$defaultConfigYmlFile = self::getYamlConfigFilePath() . SuiteGenerator::YAML_CODECEPTION_DIST_FILENAME;
130123
$ymlContents = null;
131124

132125
if (file_exists($configYmlFile)) {
@@ -148,4 +141,4 @@ private static function getYamlConfigFilePath()
148141
{
149142
return FilePathFormatter::format(TESTS_BP);
150143
}
151-
}
144+
}

src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
*/
3030
class SuiteGenerator
3131
{
32+
const YAML_CODECEPTION_DIST_FILENAME = 'codeception.dist.yml';
33+
const YAML_CODECEPTION_CONFIG_FILENAME = 'codeception.yml';
34+
const YAML_GROUPS_TAG = 'groups';
35+
const YAML_EXTENSIONS_TAG = 'extensions';
36+
const YAML_ENABLED_TAG = 'enabled';
37+
const YAML_COPYRIGHT_TEXT =
38+
"# Copyright © Magento, Inc. All rights reserved.\n# See COPYING.txt for license details.\n";
39+
3240
/**
3341
* Singelton Variable Instance.
3442
*

0 commit comments

Comments
 (0)