8
8
namespace Magento \FunctionalTestingFramework \Suite \Service ;
9
9
10
10
use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
11
+ use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
11
12
use Magento \FunctionalTestingFramework \Suite \SuiteGenerator ;
12
13
use Magento \FunctionalTestingFramework \Util \Path \FilePathFormatter ;
14
+ use Magento \FunctionalTestingFramework \Util \TestGenerator ;
13
15
use Symfony \Component \Yaml \Yaml ;
14
16
15
17
/**
@@ -52,7 +54,7 @@ public static function getInstance(): SuiteGeneratorService
52
54
* @return void
53
55
* @throws TestFrameworkException
54
56
*/
55
- public function clearPreviousSessionConfigEntries ()
57
+ public function clearPreviousSessionConfigEntries (): void
56
58
{
57
59
$ ymlArray = self ::getYamlFileContents ();
58
60
$ newYmlArray = $ ymlArray ;
@@ -65,7 +67,6 @@ public function clearPreviousSessionConfigEntries()
65
67
unset($ newYmlArray [SuiteGenerator::YAML_EXTENSIONS_TAG ][SuiteGenerator::YAML_ENABLED_TAG ][$ key ]);
66
68
}
67
69
}
68
-
69
70
// needed for proper yml file generation based on indices
70
71
$ newYmlArray [SuiteGenerator::YAML_EXTENSIONS_TAG ][SuiteGenerator::YAML_ENABLED_TAG ] =
71
72
array_values ($ newYmlArray [SuiteGenerator::YAML_EXTENSIONS_TAG ][SuiteGenerator::YAML_ENABLED_TAG ]);
@@ -74,7 +75,6 @@ public function clearPreviousSessionConfigEntries()
74
75
if (array_key_exists (SuiteGenerator::YAML_GROUPS_TAG , $ newYmlArray )) {
75
76
unset($ newYmlArray [SuiteGenerator::YAML_GROUPS_TAG ]);
76
77
}
77
-
78
78
$ ymlText = SuiteGenerator::YAML_COPYRIGHT_TEXT . Yaml::dump ($ newYmlArray , 10 );
79
79
file_put_contents (self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME , $ ymlText );
80
80
}
@@ -91,7 +91,7 @@ public function clearPreviousSessionConfigEntries()
91
91
* @return void
92
92
* @throws TestFrameworkException
93
93
*/
94
- public function appendEntriesToConfig (string $ suiteName , string $ suitePath , ?string $ groupNamespace )
94
+ public function appendEntriesToConfig (string $ suiteName , string $ suitePath , ?string $ groupNamespace ): void
95
95
{
96
96
$ relativeSuitePath = substr ($ suitePath , strlen (TESTS_BP ));
97
97
$ relativeSuitePath = ltrim ($ relativeSuitePath , DIRECTORY_SEPARATOR );
@@ -110,6 +110,23 @@ public function appendEntriesToConfig(string $suiteName, string $suitePath, ?str
110
110
file_put_contents (self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME , $ ymlText );
111
111
}
112
112
113
+ /**
114
+ * Function which takes a string which is the desired output directory (under _generated) and an array of tests
115
+ * relevant to the suite to be generated. The function takes this information and creates a new instance of the
116
+ * test generator which is then called to create all the test files for the suite.
117
+ *
118
+ * @param string $path
119
+ * @param array $tests
120
+ *
121
+ * @return void
122
+ * @throws TestReferenceException
123
+ */
124
+ public function generateRelevantGroupTests (string $ path , array $ tests ): void
125
+ {
126
+ $ testGenerator = TestGenerator::getInstance ($ path , $ tests );
127
+ $ testGenerator ->createAllTestFiles (null , []);
128
+ }
129
+
113
130
/**
114
131
* Function to return contents of codeception.yml file for config changes.
115
132
*
@@ -120,7 +137,6 @@ private static function getYamlFileContents(): array
120
137
{
121
138
$ configYmlFile = self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME ;
122
139
$ defaultConfigYmlFile = self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_DIST_FILENAME ;
123
- $ ymlContents = null ;
124
140
125
141
if (file_exists ($ configYmlFile )) {
126
142
$ ymlContents = file_get_contents ($ configYmlFile );
@@ -137,7 +153,7 @@ private static function getYamlFileContents(): array
137
153
* @return string
138
154
* @throws TestFrameworkException
139
155
*/
140
- private static function getYamlConfigFilePath ()
156
+ private static function getYamlConfigFilePath (): string
141
157
{
142
158
return FilePathFormatter::format (TESTS_BP );
143
159
}
0 commit comments