Permalink
Browse files

- Merge [3853].

  • Loading branch information...
sebastianbergmann committed Oct 16, 2008
1 parent 3b56306 commit 289b31f81138d5e9da5278759f54e9491e0a893a
@@ -46,7 +46,7 @@ Usage: phpunit [switches] UnitTest [UnitTest.php]
--no-syntax-check Disable syntax check of test source files.
--stop-on-failure Stop execution upon first error or failure.
- --ansi Use ANSI colors in output.
+ --colors Use colors in output.
--verbose Output more verbose information.
--wait Waits for a keystroke after each test.
@@ -48,7 +48,7 @@ Usage: phpunit [switches] UnitTest [UnitTest.php]
--no-syntax-check Disable syntax check of test source files.
--stop-on-failure Stop execution upon first error or failure.
- --ansi Use ANSI colors in output.
+ --colors Use colors in output.
--verbose Output more verbose information.
--wait Waits for a keystroke after each test.
@@ -216,8 +216,8 @@ public function testGetPHPUnitConfiguration()
{
$this->assertEquals(
array (
- 'ansi' => FALSE,
'bootstrap' => '/path/to/bootstrap.php',
+ 'colors' => FALSE,
'convertErrorsToExceptions' => TRUE,
'convertNoticesToExceptions' => TRUE,
'convertWarningsToExceptions' => TRUE,
@@ -163,6 +163,7 @@ protected static function handleArguments()
$longOptions = array(
'ansi',
+ 'colors',
'bootstrap=',
'configuration=',
'coverage-html=',
@@ -228,8 +229,9 @@ protected static function handleArguments()
foreach ($options[0] as $option) {
switch ($option[0]) {
- case '--ansi': {
- $arguments['ansi'] = TRUE;
+ case '--ansi':
+ case '--colors': {
+ $arguments['colors'] = TRUE;
}
break;
@@ -672,7 +674,7 @@ public static function showHelp()
--no-syntax-check Disable syntax check of test source files.
--stop-on-failure Stop execution upon first error or failure.
- --ansi Use ANSI colors in output.
+ --colors Use colors in output.
--verbose Output more verbose information.
--wait Waits for a keystroke after each test.
@@ -97,7 +97,7 @@ class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUn
/**
* @var boolean
*/
- protected $ansi = FALSE;
+ protected $colors = FALSE;
/**
* @var boolean
@@ -114,16 +114,16 @@ class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUn
*
* @param mixed $out
* @param boolean $verbose
- * @param boolean $ansi
+ * @param boolean $colors
* @throws InvalidArgumentException
* @since Method available since Release 3.0.0
*/
- public function __construct($out = NULL, $verbose = FALSE, $ansi = FALSE)
+ public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE)
{
parent::__construct($out);
- if (is_bool($ansi)) {
- $this->ansi = $ansi;
+ if (is_bool($colors)) {
+ $this->colors = $colors;
} else {
throw new InvalidArgumentException;
}
@@ -301,7 +301,7 @@ protected function printFooter(PHPUnit_Framework_TestResult $result)
if ($result->wasSuccessful() &&
$result->allCompletlyImplemented() &&
$result->noneSkipped()) {
- if ($this->ansi) {
+ if ($this->colors) {
$this->write("\x1b[30;42m\x1b[2K");
}
@@ -316,17 +316,22 @@ protected function printFooter(PHPUnit_Framework_TestResult $result)
)
);
- if ($this->ansi) {
+ if ($this->colors) {
$this->write("\x1b[0m\x1b[2K");
}
}
else if ((!$result->allCompletlyImplemented() ||
!$result->noneSkipped())&&
$result->wasSuccessful()) {
+ if ($this->colors) {
+ $this->write("\x1b[30;43m\x1b[2KOK, but incomplete or skipped tests!\n\x1b[0m\x1b[30;43m\x1b[2K");
+ } else {
+ $this->write("OK, but incomplete or skipped tests!\n");
+ }
+
$this->write(
sprintf(
- "OK, but incomplete or skipped tests!\n" .
"Tests: %d, Assertions: %d%s%s.\n",
count($result),
@@ -335,12 +340,16 @@ protected function printFooter(PHPUnit_Framework_TestResult $result)
$this->getCountString($result->skippedCount(), 'Skipped')
)
);
+
+ if ($this->colors) {
+ $this->write("\x1b[0m\x1b[2K");
+ }
}
else {
$this->write("\n");
- if ($this->ansi) {
+ if ($this->colors) {
$this->write("\x1b[37;41m\x1b[2KFAILURES!\n\x1b[0m\x1b[37;41m\x1b[2K");
} else {
$this->write("FAILURES!\n");
@@ -359,7 +368,7 @@ protected function printFooter(PHPUnit_Framework_TestResult $result)
)
);
- if ($this->ansi) {
+ if ($this->colors) {
$this->write("\x1b[0m\x1b[2K");
}
}
@@ -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['ansi']
+ NULL, $arguments['verbose'], $arguments['colors']
);
}
}
@@ -628,8 +628,8 @@ protected function handleConfiguration(array &$arguments)
$phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
- if (isset($phpunitConfiguration['ansi']) && !isset($arguments['ansi'])) {
- $arguments['ansi'] = $phpunitConfiguration['ansi'];
+ if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
+ $arguments['colors'] = $phpunitConfiguration['colors'];
}
if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
@@ -755,7 +755,7 @@ protected function handleConfiguration(array &$arguments)
$arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
$arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
- $arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : FALSE;
+ $arguments['colors'] = isset($arguments['colors']) ? $arguments['colors'] : FALSE;
$arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
$arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
$arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
@@ -57,8 +57,8 @@
* <code>
* <?xml version="1.0" encoding="utf-8" ?>
*
- * <phpunit ansi="false"
- * bootstrap="/path/to/bootstrap.php"
+ * <phpunit bootstrap="/path/to/bootstrap.php"
+ * colors="false"
* convertErrorsToExceptions="true"
* convertNoticesToExceptions="true"
* convertWarningsToExceptions="true"
@@ -399,8 +399,15 @@ public function getPHPUnitConfiguration()
{
$result = array();
- if ($this->document->documentElement->hasAttribute('ansi')) {
- $result['ansi'] = $this->getBoolean(
+ if ($this->document->documentElement->hasAttribute('colors')) {
+ $result['colors'] = $this->getBoolean(
+ (string)$this->document->documentElement->getAttribute('colors'),
+ FALSE
+ );
+ }
+
+ else if ($this->document->documentElement->hasAttribute('ansi')) {
+ $result['colors'] = $this->getBoolean(
(string)$this->document->documentElement->getAttribute('ansi'),
FALSE
);

0 comments on commit 289b31f

Please sign in to comment.