Having just kind of gotten my head around Simpletest functional testing in Drupal 8.x, I've now started trying to use PHPUnit testing since Simpletest has been deprecated in Drupal 9.1.x.
I started by looking at the instructions on Running PHPUnit tests. However, when I get to the step on running the tests I get this.
Fatal error: Uncaught Error: Class "Drupal\Tests\node\Functional\NodeTestBase" not found in /opt/drupal/web/core/modules/node/tests/src/Functional/PagePreviewTest.php:22
This looks a bit like an autoload issue to me. I ran the following command to verify it was effectively so.
php -r "require_once('autoload.php'); var_dump(class_exists('\Drupal\Tests\node\Functional\PagePreviewTest'));"
The command outputs bool(false).
My knowledge really ends here. The documentation seems to be moot on this, and it looks like I'm not the only one with this problem. (See How to run PHPUnit tests?).
How do I run PHPUnit tests?
This is the Docker file content that can be used to reproduce what I described in the question.
FROM drupal:9.1.0
RUN composer require -n \
phpunit/phpunit:9.5.0 \
phpspec/prophecy-phpunit:2.0.1 \
symfony/phpunit-bridge:5.2.1
RUN cd web/core; phpunit -c phpunit.xml.dist modules/node/tests/src/Functional/NodeTestBase.php
Building this causes the error I described above.
9.1.x-dev
, right?core/modules/node/tests/src/Functional/NodeTestBase.php
doesn't exist?