- Issue created by @freelock
I needed to run a PHPUnit test for a contrib module that was failing. I want to be able to do this with Drupal Flake.
Not being that familiar with running PHPUnit, here's what I did to get this working, using PHPStorm to run the tests.
1. composer require --dev drupal/core-dev phpstan/phpstan
2. Copied the web/core/phpunit.xml.dist to web/phpunit.xml and set these items:
bootstrap="core/tests/bootstrap.php"
3. This DB connection string did not work -- so I had to `ln -s /home/john/git/demo/data/drupal-demo-db/mysql.sock /run/mysqld/mysqld.sock`.
4. Had to create the directory web/sites/simpletest/browser_output.
5. Needed to configure phpStorm with the nix-built PHP path -- found by using `which php` and then pasting that into the Config -> Settings -> PHP, click ... next to CLI interpreters, and paste it into the PHP Executable box.
6. Again in PHPStorm settings, Test Frameworks section -- set the Test Runner default configuration file to my phpunit.xml file.
And with that, I was able to successfully run the tests in PHPStorm, by opening a test file and clicking the "Play" button, and debug them using the Debug button.
So I see a few possible improvements here:
1. Set the default mysqli socket path in PHP to the project socket path
2. Script to auto-generate a phpunit.xml file
3. Script to automatically add/update the PHPStorm PHP interpreter path - looks like if you make a "local" php interpreter, it gets stored in .idea/php.xml file as a block like this:
<component name="PhpInterpreters">
<interpreters>
<interpreter id="02888e9e-9d2c-4b01-a3bb-7e83cba9acca" name="FlakePHP" home="/nix/store/lmgd0m2f0kaszh306bdmhs5bgjrncwbr-phpEnv/bin/php" auto="false" debugger_id="
php.debugger.XDebug" />
</interpreters>
</component>
... along with a block...
4. Auto-configuration for vscode???
Determine what to improve. Improve it.
New commands for setting up test infrastructure.
Active
Documentation