Skip to content

Fails with PHPUnit 7.5: Cannot access private property $anyBarEnabled #169

Closed
@mbrodala

Description

@mbrodala

With PHPUnit 7.5 the result printer fails:

PHPUnit Pretty Result Printer 0.28.0 by Codedungeon and contributors.
==> Configuration: /var/www/html/vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml

PHPUnit 7.5.20 by Sebastian Bergmann and contributors.


 ==> FooTest        ✔  ✔  ✔  ✔  

Time: 64 ms, Memory: 10.00 MB

OK (10 tests, 14 assertions)
PHP Fatal error:  Uncaught Error: Cannot access private property Codedungeon\PHPUnitPrettyResultPrinter\Printer::$anyBarEnabled in /var/www/html/vendor/codedungeon/phpunit-result-printer/src/ResultPrinter71.php:42
Stack trace:
#0 /var/www/html/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(194): Codedungeon\PHPUnitPrettyResultPrinter\ResultPrinter71->printFooter(Object(PHPUnit\Framework\TestResult))
#1 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(663): PHPUnit\TextUI\ResultPrinter->printResult(Object(PHPUnit\Framework\TestResult))
#2 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(206): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
#3 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)
#4 /var/www/html/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#5 {main}
  thrown in /var/www/html/vendor/codedungeon/phpunit-result-printer/src/ResultPrinter71.php on line 42

Fatal error: Uncaught Error: Cannot access private property Codedungeon\PHPUnitPrettyResultPrinter\Printer::$anyBarEnabled in /var/www/html/vendor/codedungeon/phpunit-result-printer/src/ResultPrinter71.php:42
Stack trace:
#0 /var/www/html/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(194): Codedungeon\PHPUnitPrettyResultPrinter\ResultPrinter71->printFooter(Object(PHPUnit\Framework\TestResult))
#1 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(663): PHPUnit\TextUI\ResultPrinter->printResult(Object(PHPUnit\Framework\TestResult))
#2 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(206): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
#3 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)
#4 /var/www/html/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#5 {main}
  thrown in /var/www/html/vendor/codedungeon/phpunit-result-printer/src/ResultPrinter71.php on line 42
Script phpunit --colors=always handling the test:unit event returned with error code 255

The installed packages:

$ composer show "*phpunit*"
codedungeon/phpunit-result-printer 0.29.1 PHPUnit Pretty Result Printer
phpunit/php-code-coverage          6.1.4  Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          2.0.2  FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template          1.2.1  Simple template engine.
phpunit/php-timer                  2.1.2  Utility class for timing
phpunit/php-token-stream           3.1.1  Wrapper around PHP's tokenizer extension.
phpunit/phpunit                    7.5.20 The PHP Unit Testing framework.

If I move the use PrinterTrait from Printer.php to ResultPrinter71.php the issue is gone. I'd recommend doing that anyways since it makes the code way easier to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions