I am trying to find out why my PHPUnit tests fail with the following messages:
PHP Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /var/www/html/core/tests/bootstrap.php on line 197
Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /var/www/html/core/tests/bootstrap.php on line 197
PHP Warning: Class 'Drupal\TestTools\PhpUnitCompatibility\PhpUnit8\HtmlOutputPrinter' not found in /var/www/html/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php on line 15
Warning: Class 'Drupal\TestTools\PhpUnitCompatibility\PhpUnit8\HtmlOutputPrinter' not found in /var/www/html/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php on line 15
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
Could not use "\Drupal\Tests\Listeners\HtmlOutputPrinter" as printer: class does not exist
I executed ../vendor/bin/phpunit ../modules/custom/drupalup_fibo_test/
from inside the core directory and the errors above came pouring out even though I followed this tutorial and used the tutors finished code available from github.
I also get the same messages with my own custom module.
The last line of the output complaining about HtmlOutputPrinter can be silenced by commenting out a relevant line in core/phpunit.xml.
My research led me to this issue log and other similar issues where PHPUnit 6 and PHP compatibility issues seemed to be the problem. My Drupal site is Docker powered, using PHPUnit 8.5.2 and running PHP 7.3.13.