Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Merge [3963].

  • Loading branch information...
commit 1869111d5778f1a2686d6a83687a5835fa19ba77 1 parent 113144b
@sebastianbergmann authored
View
24 PHPUnit/Tests/TextUI/debug.phpt
@@ -0,0 +1,24 @@
+--TEST--
+phpunit --debug BankAccountTest ../../Samples/BankAccount/BankAccountTest.php
+--FILE--
+<?php
+$_SERVER['argv'][1] = '--debug';
+$_SERVER['argv'][2] = 'BankAccountTest';
+$_SERVER['argv'][3] = '../Samples/BankAccount/BankAccountTest.php';
+
+require_once dirname(dirname(dirname(__FILE__))) . '/TextUI/Command.php';
+?>
+--EXPECTF--
+PHPUnit %s by Sebastian Bergmann.
+
+
+Starting test 'testBalanceIsInitiallyZero(BankAccountTest)'.
+.
+Starting test 'testBalanceCannotBecomeNegative(BankAccountTest)'.
+.
+Starting test 'testBalanceCannotBecomeNegative2(BankAccountTest)'.
+.
+
+Time: %i seconds
+
+OK (3 tests, 3 assertions)
View
6 PHPUnit/TextUI/Command.php
@@ -170,6 +170,7 @@ protected static function handleArguments()
'coverage-clover=',
'coverage-source=',
'coverage-xml=',
+ 'debug',
'exclude-group=',
'filter=',
'group=',
@@ -304,6 +305,11 @@ protected static function handleArguments()
}
break;
+ case '--debug': {
+ $arguments['debug'] = TRUE;
+ }
+ break;
+
case '--help': {
self::showHelp();
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
View
23 PHPUnit/TextUI/ResultPrinter.php
@@ -47,6 +47,7 @@
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Util/Filter.php';
require_once 'PHPUnit/Util/Printer.php';
+require_once 'PHPUnit/Util/Test.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
@@ -102,6 +103,11 @@ class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUn
/**
* @var boolean
*/
+ protected $debug = FALSE;
+
+ /**
+ * @var boolean
+ */
protected $verbose = FALSE;
/**
@@ -115,10 +121,11 @@ class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUn
* @param mixed $out
* @param boolean $verbose
* @param boolean $colors
+ * @param boolean $debug
* @throws InvalidArgumentException
* @since Method available since Release 3.0.0
*/
- public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE)
+ public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE, $debug = FALSE)
{
parent::__construct($out);
@@ -128,6 +135,12 @@ public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE)
throw new InvalidArgumentException;
}
+ if (is_bool($debug)) {
+ $this->debug = $debug;
+ } else {
+ throw new InvalidArgumentException;
+ }
+
if (is_bool($verbose)) {
$this->verbose = $verbose;
} else {
@@ -532,6 +545,14 @@ public function startTest(PHPUnit_Framework_Test $test)
}
$this->lastEvent = self::EVENT_TEST_START;
+
+ if ($this->debug) {
+ $this->write(
+ sprintf(
+ "\nStarting test '%s'.\n", PHPUnit_Util_Test::describe($test)
+ )
+ );
+ }
}
/**
View
3  PHPUnit/TextUI/TestRunner.php
@@ -191,7 +191,7 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
$this->printer = $arguments['printer'];
} else {
$this->printer = new PHPUnit_TextUI_ResultPrinter(
- NULL, $arguments['verbose'], $arguments['colors']
+ NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']
);
}
}
@@ -574,6 +574,7 @@ protected function handleConfiguration(array &$arguments)
$arguments['pmd'] = array();
}
+ $arguments['debug'] = isset($arguments['debug']) ? $arguments['debug'] : FALSE;
$arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE;
View
1  package.xml
@@ -811,6 +811,7 @@
<file baseinstalldir="/" name="coverage-clover-public.phpt" role="test" />
<file baseinstalldir="/" name="coverage-source.phpt" role="test" />
<file baseinstalldir="/" name="dataset-log-xml.phpt" role="test" />
+ <file baseinstalldir="/" name="debug.phpt" role="test" />
<file baseinstalldir="/" name="default.phpt" role="test" />
<file baseinstalldir="/" name="exclude-group.phpt" role="test" />
<file baseinstalldir="/" name="filter-class.phpt" role="test" />
Please sign in to comment.
Something went wrong with that request. Please try again.