88namespace Magento \FunctionalTestingFramework \Suite \Service ;
99
1010use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
11+ use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
1112use Magento \FunctionalTestingFramework \Suite \SuiteGenerator ;
1213use Magento \FunctionalTestingFramework \Util \Path \FilePathFormatter ;
14+ use Magento \FunctionalTestingFramework \Util \TestGenerator ;
1315use Symfony \Component \Yaml \Yaml ;
1416
1517/**
@@ -52,7 +54,7 @@ public static function getInstance(): SuiteGeneratorService
5254 * @return void
5355 * @throws TestFrameworkException
5456 */
55- public function clearPreviousSessionConfigEntries ()
57+ public function clearPreviousSessionConfigEntries (): void
5658 {
5759 $ ymlArray = self ::getYamlFileContents ();
5860 $ newYmlArray = $ ymlArray ;
@@ -65,7 +67,6 @@ public function clearPreviousSessionConfigEntries()
6567 unset($ newYmlArray [SuiteGenerator::YAML_EXTENSIONS_TAG ][SuiteGenerator::YAML_ENABLED_TAG ][$ key ]);
6668 }
6769 }
68-
6970 // needed for proper yml file generation based on indices
7071 $ newYmlArray [SuiteGenerator::YAML_EXTENSIONS_TAG ][SuiteGenerator::YAML_ENABLED_TAG ] =
7172 array_values ($ newYmlArray [SuiteGenerator::YAML_EXTENSIONS_TAG ][SuiteGenerator::YAML_ENABLED_TAG ]);
@@ -74,7 +75,6 @@ public function clearPreviousSessionConfigEntries()
7475 if (array_key_exists (SuiteGenerator::YAML_GROUPS_TAG , $ newYmlArray )) {
7576 unset($ newYmlArray [SuiteGenerator::YAML_GROUPS_TAG ]);
7677 }
77-
7878 $ ymlText = SuiteGenerator::YAML_COPYRIGHT_TEXT . Yaml::dump ($ newYmlArray , 10 );
7979 file_put_contents (self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME , $ ymlText );
8080 }
@@ -91,7 +91,7 @@ public function clearPreviousSessionConfigEntries()
9191 * @return void
9292 * @throws TestFrameworkException
9393 */
94- public function appendEntriesToConfig (string $ suiteName , string $ suitePath , ?string $ groupNamespace )
94+ public function appendEntriesToConfig (string $ suiteName , string $ suitePath , ?string $ groupNamespace ): void
9595 {
9696 $ relativeSuitePath = substr ($ suitePath , strlen (TESTS_BP ));
9797 $ relativeSuitePath = ltrim ($ relativeSuitePath , DIRECTORY_SEPARATOR );
@@ -110,6 +110,23 @@ public function appendEntriesToConfig(string $suiteName, string $suitePath, ?str
110110 file_put_contents (self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME , $ ymlText );
111111 }
112112
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+
113130 /**
114131 * Function to return contents of codeception.yml file for config changes.
115132 *
@@ -120,7 +137,6 @@ private static function getYamlFileContents(): array
120137 {
121138 $ configYmlFile = self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME ;
122139 $ defaultConfigYmlFile = self ::getYamlConfigFilePath () . SuiteGenerator::YAML_CODECEPTION_DIST_FILENAME ;
123- $ ymlContents = null ;
124140
125141 if (file_exists ($ configYmlFile )) {
126142 $ ymlContents = file_get_contents ($ configYmlFile );
@@ -137,7 +153,7 @@ private static function getYamlFileContents(): array
137153 * @return string
138154 * @throws TestFrameworkException
139155 */
140- private static function getYamlConfigFilePath ()
156+ private static function getYamlConfigFilePath (): string
141157 {
142158 return FilePathFormatter::format (TESTS_BP );
143159 }
0 commit comments