fix bootstrap/classloading

Merged DaveD requested to merge classloader into master

The main points here are:

  • We need drupal's bootstrap file to run, but you can't "chain" or "hook" into it. So I've copied it to the extension folder to bootstrap.mink.php and edited it.
    • The obvious part is adding $loader->add('Civi') etc.
    • The less obvious part is that when the regular drupal one is used, it knows where it is since it's always in the same place, so it's easy to find the drupal root. But when it's inside an extension, that extension could be anywhere not even under the drupal project. So I've added a function that will try to guess, but also let's you specify a path in phpunit.mink.xml if you have a fancy setup.
    • This strategy means it will need to be kept updated if there are changes to drupal's core bootstrap. That's not much different than other extension files like upgrader.php. But maybe there's something better.
  • I had originally changed the requirement so that the test files now need to be under Civi not mink and instead you need to annotate with @group mink. But that was thwarted because if you have "regular" unit tests under Civi, then when they run they still load/parse the mink tests in order to even determine what group they are in, so that loading fails since it's a different bootstrap.
    • So I used a separate Mink folder and then also had to update bootstrap for the non-PSR0 path.
  • The "regular" bootstrap.php included in this PR isn't used here in mink tests, but is an example of what I would now start typically using for regular tests.

So the typical command for running a test would now be:

cd /path/to/your/extension
/path/to/drupal/project/root/vendor/bin/phpunit -c phpunit.mink.xml [--group mink] tests/phpunit/Mink
Edited by DaveD

Merge request reports