Skip to content

Commit

Permalink
Fixed test coverage issues with ResultPrinter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfour-merickson committed Apr 17, 2018
1 parent f056b81 commit f591cff
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 49 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codedungeon/phpunit-result-printer",
"version": "0.16.0",
"version": "0.16.1",
"description": "PHPUnit Pretty Result Printer",
"keywords": [
"phpunit",
Expand Down Expand Up @@ -37,7 +37,10 @@
"scripts": {
"coverage-report": "open ./coverage/index.html",
"test": "vendor/bin/phpunit --colors=always",
"test-coverage": "./vendor/bin/phpunit --colors=always --testsuite Unit --coverage-html coverage",
"test-coverage": [
"./vendor/bin/phpunit --colors=always --testsuite Unit --coverage-html coverage",
"open ./coverage/index.html"
],
"test-ci": "vendor/bin/phpunit -c phpunit.ci.xml",
"test-watch": "vendor/bin/phpunit-watcher watch --testsuite Unit < /dev/tty",
"watch-tickets": "vendor/bin/phpunit-watcher watch --testsuite Tickets < /dev/tty"
Expand Down
14 changes: 8 additions & 6 deletions src/ResultPrinter5.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
use PHPUnit_Framework_Test;
use PHPUnit_TextUI_ResultPrinter;

class ResultPrinter5 extends PHPUnit_TextUI_ResultPrinter
{
public function startTest(PHPUnit_Framework_Test $test)
if (class_exists(PHPUnit_TextUI_ResultPrinter::class)) {
class ResultPrinter5 extends PHPUnit_TextUI_ResultPrinter
{
$this->className = \get_class($test);
parent::startTest($test);
public function startTest(PHPUnit_Framework_Test $test)
{
$this->className = \get_class($test);
parent::startTest($test);
}
}
}
}
31 changes: 17 additions & 14 deletions src/ResultPrinter6.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
namespace Codedungeon\PHPUnitPrettyResultPrinter;

use PHPUnit\Framework\Test;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\ResultPrinter;

class ResultPrinter6 extends ResultPrinter
{
public function startTest(Test $test)
if (version_compare(Version::series(), '6.99.99', '<=')) {
class ResultPrinter6 extends ResultPrinter
{
$this->className = \get_class($test);
parent::startTest($test);
}
public function startTest(Test $test)
{
$this->className = \get_class($test);
parent::startTest($test);
}

protected function writeProgress($progress)
{
$this->writeProgressEx($progress);
}
protected function writeProgress($progress)
{
$this->writeProgressEx($progress);
}

protected function writeProgressWithColor($progress, $buffer)
{
$this->writeProgressWithColorEx($progress, $buffer);
protected function writeProgressWithColor($progress, $buffer)
{
$this->writeProgressWithColorEx($progress, $buffer);
}
}
}
}
32 changes: 19 additions & 13 deletions src/ResultPrinter70.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@
namespace Codedungeon\PHPUnitPrettyResultPrinter;

use PHPUnit\Framework\Test;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\ResultPrinter;

class ResultPrinter70 extends ResultPrinter
{
public function startTest(Test $test): void
{
$this->className = \get_class($test);
parent::startTest($test);
}
$low = version_compare(Version::series(), '7.0', '>=');
$high = version_compare(Version::series(), '7.0.99', '<=');

protected function writeProgress($progress): void
if ($low && $high) {
class ResultPrinter70 extends ResultPrinter
{
$this->writeProgressEx($progress);
}
public function startTest(Test $test): void
{
$this->className = \get_class($test);
parent::startTest($test);
}

protected function writeProgressWithColor($progress, $buffer): void
{
$this->writeProgressWithColorEx($progress, $buffer);
protected function writeProgress($progress): void
{
$this->writeProgressEx($progress);
}

protected function writeProgressWithColor($progress, $buffer): void
{
$this->writeProgressWithColorEx($progress, $buffer);
}
}
}
37 changes: 23 additions & 14 deletions src/ResultPrinter71.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
namespace Codedungeon\PHPUnitPrettyResultPrinter;

use PHPUnit\Framework\Test;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\ResultPrinter;

class ResultPrinter71 extends ResultPrinter
{
public function startTest(Test $test): void
{
$this->className = \get_class($test);
parent::startTest($test);
}
$low = version_compare(Version::series(), '7.1', '>=');
$high = true; // version_compare(Version::series(),'7.1.99','<=');

protected function writeProgress(string $progress): void
{
$this->writeProgressEx($progress);
}
if ($low && $high) {

protected function writeProgressWithColor(string $progress, string $buffer): void

class ResultPrinter71 extends ResultPrinter
{
$this->writeProgressWithColorEx($progress, $buffer);
public function startTest(Test $test): void
{
$this->className = \get_class($test);
parent::startTest($test);
}

protected function writeProgress(string $progress): void
{
$this->writeProgressEx($progress);
}

protected function writeProgressWithColor(string $progress, string $buffer): void
{
$this->writeProgressWithColorEx($progress, $buffer);
}
}
}

}

0 comments on commit f591cff

Please sign in to comment.