webksde / ddev-vscode-devcontainer-drupal-template

Drupal DDEV based development container with attached Visual Studio Code
23 stars 3 forks source link

Fix `ddev phpunit` command when initializing the project with `ddev drowl-init-dev` #173

Open joshsedl opened 2 months ago

joshsedl commented 2 months ago

Our ddev drowl-init-dev command initiates drupal using Joachims drupal-core-development-project. And because of the symlink created on the vendor/folder, the phpunit ddev command fails with the following error:

PHP Warning:  require(/var/www/html/repos/drupal/vendor/autoload.php): Failed to open stream: No such file or directory in /var/www/html/repos/drupal/autoload.php on line 13

see https://github.com/joachim-n/drupal-core-development-project/issues/14 for more information. For the time being you can execute core tests, executing vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php from the project root, but that requires the current php version installed locally on your computer instead of it being installed in your container instance.

joshsedl commented 2 months ago

Ok, the provided error doesn't come from the symlink issue. In the symlinked drupal repo, we get untracked "sites/simpletest" and "vendor" folders, which we remove on "ddev drowl-init-dev". These are actually required for phpunit to work for some reason. But they show up as untracked files, when working in core issues (so we removed them on init). THESE files are required for core tests to be exectued with ddev phpunit. To get these files back, simply require any existing package (e.g. ddev composer require composer-runtime-api), and they will appear again and you will be able to test. BUT CAREFUL! Do NOT commit them into core issues!

joshsedl commented 2 months ago

Note, also set the "BROWSERTEST_OUTPUT_BASE_URL" in your phpunit.xml accordingly.