Permalink
Browse files

MDL-34893 use standard options in Hint_ResultPrinter

This is a very nasty hack!
  • Loading branch information...
1 parent 7033316 commit db6842cca31887e5110a267977820fe805da0007 @skodak skodak committed Aug 19, 2012
Showing with 41 additions and 1 deletion.
  1. +41 −0 lib/phpunit/classes/hint_resultprinter.php
  2. +0 −1 phpunit.xml.dist
@@ -34,6 +34,20 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class Hint_ResultPrinter extends PHPUnit_TextUI_ResultPrinter {
+ public function __construct() {
+ // ARRGH - PHPUnit does not give us commandline arguments or xml config, so let's hack hard!
+ if (defined('DEBUG_BACKTRACE_PROVIDE_OBJECT')) {
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
+ if (isset($backtrace[2]['object']) and ($backtrace[2]['object'] instanceof PHPUnit_TextUI_Command)) {
+ list($verbose, $colors, $debug) = Hacky_TextUI_Command_reader::get_settings_hackery($backtrace[2]['object']);
+ parent::__construct(null, $verbose, $colors, $debug);
+ return;
+ }
+ }
+ // Fallback if something goes wrong.
+ parent::__construct(null, false, false, false);
+ }
+
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) {
global $CFG;
@@ -83,3 +97,30 @@ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) {
$this->write("\nTo re-run:\n $executable $testName $file\n");
}
}
+
+
+/**
+ * Class used in bloody hack that works around result printer constructor troubles.
+ *
+ * @package core
+ * @category phpunit
+ * @copyright 2012 Petr Skoda {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class Hacky_TextUI_Command_reader extends PHPUnit_TextUI_Command {
+ public static function get_settings_hackery(PHPUnit_TextUI_Command $toread) {
+ $arguments = $toread->arguments;
+ $config = PHPUnit_Util_Configuration::getInstance($arguments['configuration'])->getPHPUnitConfiguration();
+
+ $verbose = isset($config['verbose']) ? $config['verbose'] : false;
+ $verbose = isset($arguments['verbose']) ? $arguments['verbose'] : $verbose;
+
+ $colors = isset($config['colors']) ? $config['colors'] : false;
+ $colors = isset($arguments['colors']) ? $arguments['colors'] : $colors;
+
+ $debug = isset($config['debug']) ? $config['debug'] : false;
+ $debug = isset($arguments['debug']) ? $arguments['debug'] : $debug;
+
+ return array($verbose, $colors, $debug);
+ }
+}
View
@@ -14,7 +14,6 @@
stopOnIncomplete="false"
stopOnSkipped="false"
strict="false"
- verbose="false"
printerClass="Hint_ResultPrinter"
>

0 comments on commit db6842c

Please sign in to comment.