public function run(rex_test_locator $locator, $colors = false) { $suite = new PHPUnit_Framework_TestSuite(); // disable backup of globals, since we have some rex_sql objectes referenced from variables in global space. // PDOStatements are not allowed to be serialized $suite->setBackupGlobals(false); $suite->addTestFiles($locator->getIterator()); rex_error_handler::unregister(); $runner = new PHPUnit_TextUI_TestRunner(); $backtrace = debug_backtrace(false); array_unshift($backtrace, ['file' => __FILE__, 'line' => __LINE__ + 3]); $runner->setPrinter(new rex_tests_result_printer($backtrace, $colors)); $result = $runner->doRun($suite); rex_error_handler::register(); return $result; }
<?php echo rex_view::title('TestResults'); $runner = new rex_test_runner(); $runner->setUp(); echo '<pre>'; $runner->run(rex_test_locator::defaultLocator()); echo '</pre>';
if (PHP_SAPI !== 'cli') { echo 'error: this script may only be run from CLI'; return 1; } // bring the file into context, no matter from which dir it was executed $path = explode(DIRECTORY_SEPARATOR, __DIR__); do { $part = array_pop($path); } while ($part !== null && $part != 'redaxo'); if (!chdir(implode(DIRECTORY_SEPARATOR, $path) . '/redaxo')) { echo 'error: start this script within a redaxo projects folder'; return 2; } // ---- bootstrap REX $REX = []; $REX['REDAXO'] = true; $REX['HTDOCS_PATH'] = '../'; $REX['BACKEND_FOLDER'] = 'redaxo'; // bootstrap core require 'src/core/boot.php'; // bootstrap addons include_once rex_path::core('packages.php'); while (ob_get_level()) { ob_end_clean(); } // https://github.com/symfony/symfony/blob/f53297681a7149f2a809da12ea3a8b8cfd4d3025/src/Symfony/Component/Console/Output/StreamOutput.php#L103-112 $hasColorSupport = DIRECTORY_SEPARATOR == '\\' ? getenv('ANSICON') !== false : function_exists('posix_isatty') && @posix_isatty(STDOUT); $runner = new rex_test_runner(); $runner->setUp(); $result = $runner->run(rex_test_locator::defaultLocator(), $hasColorSupport); exit($result->wasSuccessful() ? 0 : 99);