sebastianbergmann / phpcov

TextUI frontend for php-code-coverage
BSD 3-Clause "New" or "Revised" License
223 stars 58 forks source link

Fixed text reporting (missing constructor arguments) #46

Closed michaldudek closed 8 years ago

michaldudek commented 8 years ago

Arguments for constructor of PHP_CodeCoverage_Report_Text were missing and they are required.

When running phpcov I got this:

$ php ./vendor/bin/phpcov merge --text true --html tests/coverage tests/coverage
phpcov 3.0.0 by Sebastian Bergmann.

Generating code coverage report in HTML format ... done
PHP Warning:  Missing argument 1 for PHP_CodeCoverage_Report_Text::__construct(), called in /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/phpcov/src/BaseCommand.php on line 194 and defined in /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Text.php on line 34
PHP Stack trace:
PHP   1. {main}() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/phpcov/phpcov:0
PHP   2. Symfony\Component\Console\Application->run() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/phpcov/phpcov:31
PHP   3. SebastianBergmann\PHPCOV\Application->doRun() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/symfony/console/Application.php:117
PHP   4. Symfony\Component\Console\Application->doRun() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/phpcov/src/Application.php:59
PHP   5. Symfony\Component\Console\Application->doRunCommand() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/symfony/console/Application.php:186
PHP   6. Symfony\Component\Console\Command\Command->run() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/symfony/console/Application.php:791
PHP   7. SebastianBergmann\PHPCOV\MergeCommand->execute() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/symfony/console/Command/Command.php:256
PHP   8. SebastianBergmann\PHPCOV\BaseCommand->handleReports() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/phpcov/src/MergeCommand.php:104
PHP   9. PHP_CodeCoverage_Report_Text->__construct() /Users/michal/Developer/WebDeveloper/Neverbland/CMSAdmin/backend/vendor/phpunit/phpcov/src/BaseCommand.php:194

and so on (many more errors).

This PR fixes it by passing the required constructor arguments based on few added CLI options - and their default values based on PHPUnit values.

The added options are:

The last 3 only apply to --text report.

I also fixed an issue that Text report was not displaying - as the writer just returns a string to be output, doesn't write to stdout itself.

And finally I slightly changed behavior of --text option - it longer requires a value, but instead it is possible to configure whether it should use colored output or not via --show-colors option.

webysther commented 8 years ago

Great job.

sebastianbergmann commented 8 years ago

Please send separate pull requests for the fix and the enhancements, thanks.