diff --git a/composer.json b/composer.json index 2712eb8..92c6e73 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "codedungeon/phpunit-result-printer", - "version": "0.16.0", + "version": "0.16.1", "description": "PHPUnit Pretty Result Printer", "keywords": [ "phpunit", @@ -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" diff --git a/src/ResultPrinter5.php b/src/ResultPrinter5.php index 787bd59..814b6dc 100644 --- a/src/ResultPrinter5.php +++ b/src/ResultPrinter5.php @@ -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); + } } -} +} \ No newline at end of file diff --git a/src/ResultPrinter6.php b/src/ResultPrinter6.php index 5d5b827..7b67df1 100644 --- a/src/ResultPrinter6.php +++ b/src/ResultPrinter6.php @@ -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); + } } -} +} \ No newline at end of file diff --git a/src/ResultPrinter70.php b/src/ResultPrinter70.php index 1b32082..41e3536 100644 --- a/src/ResultPrinter70.php +++ b/src/ResultPrinter70.php @@ -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); + } } } diff --git a/src/ResultPrinter71.php b/src/ResultPrinter71.php index 57e8dff..0a0f453 100644 --- a/src/ResultPrinter71.php +++ b/src/ResultPrinter71.php @@ -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); + } } -} + +} \ No newline at end of file