Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore phpunit.xml schema compatibility, colors=always only allowed fro... #1529

Merged
merged 3 commits into from
Dec 15, 2014
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions src/Util/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,13 @@ public function getPHPUnitConfiguration()
}

if ($root->hasAttribute('colors')) {
$result['colors'] = $this->getColorFlag(
(string) $root->getAttribute('colors'),
PHPUnit_TextUI_ResultPrinter::COLOR_DEFAULT
);
/* only allow boolean for compatibility with previous verions
'always' only allowed from command line */
if ($this->getBoolean($root->getAttribute('colors'), false)) {
$result['colors'] = PHPUnit_TextUI_ResultPrinter::COLOR_AUTO;
} else {
$result['colors'] = PHPUnit_TextUI_ResultPrinter::COLOR_DEFAULT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you should use PHPUnit_TextUI_ResultPrinter::COLOR_NEVER instead, since it is the opposite of PHPUnit_TextUI_ResultPrinter::COLOR_AUTO.

}
}

/**
Expand Down Expand Up @@ -980,30 +983,6 @@ protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter = nu
return $suite;
}

/**
* @param string $value
* @param boolean $default
* @return boolean
*/
protected function getColorFlag($value, $default)
{
$currentValue = strtolower($value);

if (in_array($currentValue, array('true', 'auto'))) {
return PHPUnit_TextUI_ResultPrinter::COLOR_AUTO;
}

if (in_array($currentValue, array('false', 'never'))) {
return PHPUnit_TextUI_ResultPrinter::COLOR_NEVER;
}

if (in_array($currentValue, array('always'))) {
return PHPUnit_TextUI_ResultPrinter::COLOR_ALWAYS;
}

return $default;
}

/**
* @param string $value
* @param boolean $default
Expand Down