Currently it doesn't seem like there's any way of running kernel tests in a multisite setup, where a module is within a site's directory.
Where a module exists at drupal_root/sites/sitename/modules/custom/my_module
, it doesn't seem possible to run PHPUnit kernel tests for any tests within that module. (I'd assume functional tests too, but I can't get those working on my machine right now :D)
The problem comes right at the start during setup:
public static $modules = ['my_module'];
It seems that this is because Simpletest installs itself in a new site directory, eg drupal_root/sites/simpletest/
, it doesn't have access to the modules in the other directory. As far as I can tell the only directories it scans are drupal_root/core
, drupal_root/sites/all
, drupal_root
and drupal_root/sites/simpletest/###
This was while running the tests directly, eg $ phpunit drupal_root/sites/sitename/modules/custom/my_module/tests/src/NameOfTest.php
, so it wasn't an automated discovery/testsuite issue.
If there is a way of running PHPUnit tests within a multisite installation then it doesn't seem to be documented anywhere. This seems like a pretty major omission.
Would it be possible for example to pass in a "site" paramater to the PHPUnit command, so that it runs within a particular site directory? Or allow discovery of modules from other directories?