Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
112
vendor/phpunit/php-code-coverage/src/Report/Text.php
vendored
112
vendor/phpunit/php-code-coverage/src/Report/Text.php
vendored
@@ -19,29 +19,59 @@ use SebastianBergmann\CodeCoverage\Util;
|
||||
*
|
||||
* The output gets put into a text file our written to the CLI.
|
||||
*/
|
||||
class Text
|
||||
final class Text
|
||||
{
|
||||
private $lowUpperBound;
|
||||
private $highLowerBound;
|
||||
private $showUncoveredFiles;
|
||||
private $showOnlySummary;
|
||||
|
||||
private $colors = [
|
||||
'green' => "\x1b[30;42m",
|
||||
'yellow' => "\x1b[30;43m",
|
||||
'red' => "\x1b[37;41m",
|
||||
'header' => "\x1b[1;37;40m",
|
||||
'reset' => "\x1b[0m",
|
||||
'eol' => "\x1b[2K",
|
||||
];
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const COLOR_GREEN = "\x1b[30;42m";
|
||||
|
||||
/**
|
||||
* @param int $lowUpperBound
|
||||
* @param int $highLowerBound
|
||||
* @param bool $showUncoveredFiles
|
||||
* @param bool $showOnlySummary
|
||||
* @var string
|
||||
*/
|
||||
public function __construct($lowUpperBound = 50, $highLowerBound = 90, $showUncoveredFiles = false, $showOnlySummary = false)
|
||||
private const COLOR_YELLOW = "\x1b[30;43m";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const COLOR_RED = "\x1b[37;41m";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const COLOR_HEADER = "\x1b[1;37;40m";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const COLOR_RESET = "\x1b[0m";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const COLOR_EOL = "\x1b[2K";
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $lowUpperBound;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $highLowerBound;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showUncoveredFiles;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showOnlySummary;
|
||||
|
||||
public function __construct(int $lowUpperBound = 50, int $highLowerBound = 90, bool $showUncoveredFiles = false, bool $showOnlySummary = false)
|
||||
{
|
||||
$this->lowUpperBound = $lowUpperBound;
|
||||
$this->highLowerBound = $highLowerBound;
|
||||
@@ -49,17 +79,10 @@ class Text
|
||||
$this->showOnlySummary = $showOnlySummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CodeCoverage $coverage
|
||||
* @param bool $showColors
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function process(CodeCoverage $coverage, $showColors = false)
|
||||
public function process(CodeCoverage $coverage, bool $showColors = false): string
|
||||
{
|
||||
$output = PHP_EOL . PHP_EOL;
|
||||
$report = $coverage->getReport();
|
||||
unset($coverage);
|
||||
|
||||
$colors = [
|
||||
'header' => '',
|
||||
@@ -75,17 +98,20 @@ class Text
|
||||
$report->getNumTestedClassesAndTraits(),
|
||||
$report->getNumClassesAndTraits()
|
||||
);
|
||||
|
||||
$colors['methods'] = $this->getCoverageColor(
|
||||
$report->getNumTestedMethods(),
|
||||
$report->getNumMethods()
|
||||
);
|
||||
|
||||
$colors['lines'] = $this->getCoverageColor(
|
||||
$report->getNumExecutedLines(),
|
||||
$report->getNumExecutableLines()
|
||||
);
|
||||
$colors['reset'] = $this->colors['reset'];
|
||||
$colors['header'] = $this->colors['header'];
|
||||
$colors['eol'] = $this->colors['eol'];
|
||||
|
||||
$colors['reset'] = self::COLOR_RESET;
|
||||
$colors['header'] = self::COLOR_HEADER;
|
||||
$colors['eol'] = self::COLOR_EOL;
|
||||
}
|
||||
|
||||
$classes = \sprintf(
|
||||
@@ -169,17 +195,18 @@ class Text
|
||||
$classMethods++;
|
||||
$classStatements += $method['executableLines'];
|
||||
$coveredClassStatements += $method['executedLines'];
|
||||
|
||||
if ($method['coverage'] == 100) {
|
||||
$coveredMethods++;
|
||||
}
|
||||
}
|
||||
|
||||
$namespace = '';
|
||||
|
||||
if (!empty($class['package']['namespace'])) {
|
||||
$namespace = '\\' . $class['package']['namespace'] . '::';
|
||||
} elseif (!empty($class['package']['fullPackage'])) {
|
||||
$namespace = '@' . $class['package']['fullPackage'] . '::';
|
||||
} else {
|
||||
$namespace = '';
|
||||
}
|
||||
|
||||
$classCoverage[$namespace . $className] = [
|
||||
@@ -200,8 +227,7 @@ class Text
|
||||
$resetColor = '';
|
||||
|
||||
foreach ($classCoverage as $fullQualifiedPath => $classInfo) {
|
||||
if ($classInfo['statementsCovered'] != 0 ||
|
||||
$this->showUncoveredFiles) {
|
||||
if ($this->showUncoveredFiles || $classInfo['statementsCovered'] != 0) {
|
||||
if ($showColors) {
|
||||
$methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']);
|
||||
$linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']);
|
||||
@@ -218,7 +244,7 @@ class Text
|
||||
return $output . PHP_EOL;
|
||||
}
|
||||
|
||||
protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElements)
|
||||
private function getCoverageColor(int $numberOfCoveredElements, int $totalNumberOfElements): string
|
||||
{
|
||||
$coverage = Util::percent(
|
||||
$numberOfCoveredElements,
|
||||
@@ -226,15 +252,17 @@ class Text
|
||||
);
|
||||
|
||||
if ($coverage >= $this->highLowerBound) {
|
||||
return $this->colors['green'];
|
||||
} elseif ($coverage > $this->lowUpperBound) {
|
||||
return $this->colors['yellow'];
|
||||
return self::COLOR_GREEN;
|
||||
}
|
||||
|
||||
return $this->colors['red'];
|
||||
if ($coverage > $this->lowUpperBound) {
|
||||
return self::COLOR_YELLOW;
|
||||
}
|
||||
|
||||
return self::COLOR_RED;
|
||||
}
|
||||
|
||||
protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $precision)
|
||||
private function printCoverageCounts(int $numberOfCoveredElements, int $totalNumberOfElements, int $precision): string
|
||||
{
|
||||
$format = '%' . $precision . 's';
|
||||
|
||||
@@ -248,9 +276,9 @@ class Text
|
||||
\sprintf($format, $totalNumberOfElements) . ')';
|
||||
}
|
||||
|
||||
private function format($color, $padding, $string)
|
||||
private function format($color, $padding, $string): string
|
||||
{
|
||||
$reset = $color ? $this->colors['reset'] : '';
|
||||
$reset = $color ? self::COLOR_RESET : '';
|
||||
|
||||
return $color . \str_pad($string, $padding) . $reset . PHP_EOL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user