static function runTests($testFolder)
 {
     $output = [];
     // clean staging
     $cmds = array();
     $staging = TestConfig::getConfig('testStagingPath');
     //FileSystemTools::setPermissionsAllowEveryone($staging);
     //FileSystemTools::setPermissionsAllowEveryone(TestConfig::getConfig('testOutputPath'));
     $passedAllTests = true;
     // some sanity checking before pruning
     if (strlen(trim($staging)) > 0) {
         // clean up staging
         FileSystemTools::prune($staging);
         //return array();
         // create staging location
         @mkdir($staging . DS . 'tests', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_support', 0777, true);
         // copy shared test support files
         FileSystemTools::copyRecursive(TestConfig::getConfig('testSharedSupportPath'), $staging . DS . 'tests' . DS . '_support');
         //return array();
         // then copy over the top, test suites etc to staging
         FileSystemTools::copyRecursive($testFolder, $staging . DS . 'tests');
         // ensure required test directories
         @mkdir($staging . DS . 'tests' . DS . '_support', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_output', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_data', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_support' . DS . 'Helper', 0777, true);
         TestConfig::writeCodeceptionConfig();
         $objects = glob($staging . DS . 'tests' . DS . '*.suite.yml');
         if (sizeof($objects) > 0) {
             foreach ($objects as $file) {
                 if ($file == "." || $file == "..") {
                     continue;
                 }
                 TestConfig::writeWebDriverConfig($file);
             }
         }
         // cm5?
         if (strlen(trim(TestConfig::getConfig('cmFivePath'))) > 0) {
             // copy installer sql to test data directory
             copy(TestConfig::getConfig('cmFivePath') . DS . 'cache' . DS . 'install.sql', $staging . DS . 'tests' . DS . '_data' . DS . 'dump.sql');
             // copy c3.php for accptance test coverage
             if (TestConfig::getConfig('coverage')) {
                 copy(TestConfig::getConfig('testRunnerPath') . DS . 'src' . DS . 'lib' . DS . 'c3.php', TestConfig::getConfig('testRunnerPath') . DS . 'staging' . DS . 'c3.php');
             }
         }
         // build and run
         array_push($cmds, array('CODECEPTION BUILD', TestConfig::getConfig('codeception') . ' build ' . ' -c ' . $staging));
         $testParam = TestConfig::getConfig('testSuite');
         $testParam .= strlen(trim(TestConfig::getConfig('testSuite'))) > 0 ? ' ' . TestConfig::getConfig('test') : '';
         // these options conflict with coverage options below so only one set
         $coverage = ' -d --no-colors --steps ';
         if (TestConfig::getConfig('coverage')) {
             //--coverage-xml
             $coverage = ' --coverage --xml --html --coverage-html   --report ';
         }
         array_push($cmds, array('CODECEPTION RUN', TestConfig::getConfig('codeception') . ' run ' . $coverage . ' -c ' . $staging . ' ' . $testParam));
         foreach ($cmds as $cmd) {
             if (php_sapi_name() == 'cli') {
                 echo "-------------------------------------------------\n";
                 echo $cmd[0] . "\n";
                 echo $cmd[1] . "\n";
                 echo "-------------------------------------------------\n";
             } else {
                 $output[] = "-------------------------------------------------";
                 $output[] = $cmd[0];
                 $output[] = $cmd[1];
                 $output[] = "-------------------------------------------------";
             }
             $handle = popen($cmd[1], "r");
             $detailsTest = '';
             $errorActive = false;
             $testType = '';
             while (!feof($handle)) {
                 $buffer = fgets($handle);
                 //$buffer = trim(htmlspecialchars($buffer));
                 if (php_sapi_name() == 'cli') {
                     echo $buffer;
                 } else {
                     $output[] = trim($buffer);
                 }
             }
             $exitCode = pclose($handle);
             if ($exitCode > 0) {
                 $passedAllTests = false;
             }
         }
         // save output files
         $testSuiteName = str_replace(':', '_', str_replace(DS, '_', $testFolder));
         @mkdir(TestConfig::getConfig('testOutputPath') . DS . $testSuiteName);
         $output[] = "COPY test results from " . $staging . DS . 'tests' . DS . '_output' . " to " . TestConfig::getConfig('testOutputPath') . DS . $testSuiteName;
         FileSystemTools::copyRecursive($staging . DS . 'tests' . DS . '_output', TestConfig::getConfig('testOutputPath') . DS . $testSuiteName);
     }
     // clean up
     if (strlen(trim(TestConfig::getConfig('testRunnerPath'))) > 0 && file_exists(TestConfig::getConfig("testRunnerPath") . "/staging/c3.php")) {
         //unlink(TestConfig::getConfig("testRunnerPath")."/staging/c3.php");
     }
     //FileSystemTools::setPermissionsAllowEveryone($staging);
     //FileSystemTools::setPermissionsAllowEveryone(TestConfig::getConfig('testOutputPath'));
     return array('output' => $output, 'result' => $passedAllTests);
 }