@@ -102,8 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
102102 * @param OutputInterface $output
103103 * @return void
104104 * @throws TestFrameworkException
105- *
106- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
107105 */
108106 private function runTests (array $ tests , OutputInterface $ output )
109107 {
@@ -123,14 +121,7 @@ private function runTests(array $tests, OutputInterface $output)
123121 );
124122 }
125123 $ fullCommand = $ codeceptionCommand . $ testsDirectory . $ testName . ' --verbose --steps ' ;
126- $ process = new Process ($ fullCommand );
127- $ process ->setWorkingDirectory (TESTS_BP );
128- $ process ->setIdleTimeout (600 );
129- $ process ->setTimeout (0 );
130- $ subReturnCode = $ process ->run (function ($ type , $ buffer ) use ($ output ) {
131- $ output ->write ($ buffer );
132- });
133- $ this ->returnCode = max ($ this ->returnCode , $ subReturnCode );
124+ $ this ->returnCode = max ($ this ->returnCode , $ this ->executeTestCommand ($ fullCommand , $ output ));
134125 }
135126 }
136127
@@ -140,23 +131,34 @@ private function runTests(array $tests, OutputInterface $output)
140131 * @param array $suitesConfig
141132 * @param OutputInterface $output
142133 * @return void
143- *
144- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
145134 */
146135 private function runTestsInSuite (array $ suitesConfig , OutputInterface $ output )
147136 {
148137 $ codeceptionCommand = realpath (PROJECT_ROOT . '/vendor/bin/codecept ' ) . ' run functional --verbose --steps ' ;
149138 //for tests in suites, run them as a group to run before and after block
150139 foreach (array_keys ($ suitesConfig ) as $ suite ) {
151140 $ fullCommand = $ codeceptionCommand . " -g {$ suite }" ;
152- $ process = new Process ($ fullCommand );
153- $ process ->setWorkingDirectory (TESTS_BP );
154- $ process ->setIdleTimeout (600 );
155- $ process ->setTimeout (0 );
156- $ subReturnCode = $ process ->run (function ($ type , $ buffer ) use ($ output ) {
157- $ output ->write ($ buffer );
158- });
159- $ this ->returnCode = max ($ this ->returnCode , $ subReturnCode );
141+ $ this ->returnCode = max ($ this ->returnCode , $ this ->executeTestCommand ($ fullCommand , $ output ));
160142 }
161143 }
144+
145+ /**
146+ * Runs the codeception test command and returns exit code
147+ *
148+ * @param String $command
149+ * @param OutputInterface $output
150+ * @return int
151+ *
152+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
153+ */
154+ private function executeTestCommand (String $ command , OutputInterface $ output )
155+ {
156+ $ process = new Process ($ command );
157+ $ process ->setWorkingDirectory (TESTS_BP );
158+ $ process ->setIdleTimeout (600 );
159+ $ process ->setTimeout (0 );
160+ return $ process ->run (function ($ type , $ buffer ) use ($ output ) {
161+ $ output ->write ($ buffer );
162+ });
163+ }
162164}
0 commit comments