@@ -33,28 +33,52 @@ function cloneFiles()
3333 */
3434 function buildProject ()
3535 {
36+ $ this ->writeln ("<error>This command will be removed in MFTF v3.0.0. Please use bin/mftf build:project instead.</error> \n" );
3637 $ this ->cloneFiles ();
3738 $ this ->_exec ('vendor ' . DIRECTORY_SEPARATOR .'bin ' . DIRECTORY_SEPARATOR .'codecept build ' );
3839 }
3940
4041 /**
4142 * Generate all Tests in PHP.
4243 *
44+ * @param array $tests
4345 * @param array $opts
4446 * @return void
4547 */
46- function generateTests ($ opts = ['config ' => null , 'force ' => true , 'nodes ' => null ])
48+ function generateTests (array $ tests , $ opts = ['config ' => null , 'force ' => true , 'nodes ' => null , ' debug ' => false ])
4749 {
50+ require 'dev ' . DIRECTORY_SEPARATOR . 'tests ' . DIRECTORY_SEPARATOR . 'functional ' . DIRECTORY_SEPARATOR . '_bootstrap.php ' ;
4851 $ GLOBALS ['GENERATE_TESTS ' ] = true ;
49-
50- if ($ opts ['force ' ])
51- {
52+ if (!$ this ->isProjectBuilt ()) {
53+ $ this ->say ("<info>Please run bin/mftf build:project and configure your environment (.env) first.</info> " );
54+ exit (\Robo \Result::EXITCODE_ERROR );
55+ }
56+ $ testsObjects = [];
57+ foreach ($ tests as $ test ) {
58+ $ testsObjects [] = Magento \FunctionalTestingFramework \Test \Handlers \TestObjectHandler::getInstance ()->getObject ($ test );
59+ }
60+ if ($ opts ['force ' ]) {
5261 $ GLOBALS ['FORCE_PHP_GENERATE ' ] = true ;
5362 }
63+ $ testsReferencedInSuites = \Magento \FunctionalTestingFramework \Suite \SuiteGenerator::getInstance ()->generateAllSuites ($ opts ['config ' ]);
64+ \Magento \FunctionalTestingFramework \Util \TestGenerator::getInstance (null , $ testsObjects , $ opts ['debug ' ])->createAllTestFiles ($ opts ['config ' ], $ opts ['nodes ' ], $ testsReferencedInSuites );
65+ $ this ->say ("<comment>Generate Tests Command Run</comment> " );
66+ }
5467
55- require 'dev ' . DIRECTORY_SEPARATOR . 'tests ' . DIRECTORY_SEPARATOR . 'functional ' . DIRECTORY_SEPARATOR . '_bootstrap.php ' ;
56- \Magento \FunctionalTestingFramework \Util \TestGenerator::getInstance ()->createAllTestFiles ($ opts ['config ' ], $ opts ['nodes ' ]);
57- $ this ->say ("Generate Tests Command Run " );
68+ /**
69+ * Check if MFTF has been properly configured
70+ * @return bool
71+ */
72+ private function isProjectBuilt ()
73+ {
74+ $ actorFile = __DIR__ . DIRECTORY_SEPARATOR . 'src ' . DIRECTORY_SEPARATOR . 'Magento ' . DIRECTORY_SEPARATOR . 'FunctionalTestingFramework ' . DIRECTORY_SEPARATOR . '_generated ' . DIRECTORY_SEPARATOR . 'AcceptanceTesterActions.php ' ;
75+
76+ $ login = !empty (getenv ('MAGENTO_ADMIN_USERNAME ' ));
77+ $ password = !empty (getenv ('MAGENTO_ADMIN_PASSWORD ' ));
78+ $ baseUrl = !empty (getenv ('MAGENTO_BASE_URL ' ));
79+ $ backendName = !empty (getenv ('MAGENTO_BACKEND_NAME ' ));
80+ $ test = (file_exists ($ actorFile ) && $ login && $ password && $ baseUrl && $ backendName );
81+ return $ test ;
5882 }
5983
6084 /**
@@ -79,13 +103,13 @@ function generateSuite(array $args)
79103 }
80104
81105 /**
82- * Run all Functional tests.
106+ * Run all MFTF tests.
83107 *
84108 * @return void
85109 */
86- function functional ()
110+ function mftf ()
87111 {
88- $ this ->_exec ('. ' . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . 'bin ' . DIRECTORY_SEPARATOR . 'codecept run functional --skip-group skip ' );
112+ $ this ->_exec ('. ' . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . 'bin ' . DIRECTORY_SEPARATOR . 'codecept run MFTF --skip-group skip ' );
89113 }
90114
91115 /**
0 commit comments