This gist is a follow-up to this Lando issue, updated for Docker Composer and Windows (but might also help macOS and Linux users).
- Open File | Settings | Build, Execution, Deployment | Docker
- Click on the top-left "+"
- Case a: If you have (and want to use) Docker for Windows: choose "Docker for Windows"
- Case b (theorical, because unfortunately I could not get it to work): If your Lando instance is in WSL:
- Choose "WSL" and your Linux distribution
- Add one or more path mappings (in my case mapping
/home/quentint
to\\wsl$\Ubuntu\home\quentint
was enough because my projects are stored in WSL's home directory)
- Open File | Settings | Languages & Frameworks | PHP
- Click on the three dots on the "CLI Interpreter" line
- Click on the top-left "+" and create CLI Interpreter "From Docker, Vagrant, VM, WSL, Remote..."
- Choose "Docker Compose"
- Click on the "Configuration files" folder icon
- Click on the top-right "+"
- Select all YAML files in
C:\Users\[user]\.lando\compose\[project]
- Select "appserver" in the Service dropdown
- Click OK to close the "Configure Remote PHP Interpreter" window
- Choose "Connect to an existing container" in the "Lifecycle" section
- Click OK to close the "CLI Interpreters" window
- Click on the directory icon of the "Path mappings" section
- Add a local path mapping your project root to
/app
and click OK to confirm
- Open File | Settings | Languages & Frameworks | PHP | Test Frameworks
- Click the top-left "+" to add a test framework
- Choose "PHPUnit by Remote Interpreter"
- Choose your newly created interpreter and click OK to close the window
- Choose "Use Composer autoloader"
- Set "Path to script" to
/app/vendor/autoload.php
- If not already there, create
phpunit.xml.dist
at the root of your project
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true"
bootstrap="tests/bootstrap.php">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<!-- Run `composer require symfony/phpunit-bridge` before enabling this extension -->
<!--
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
-->
<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
-->
</phpunit>
- If not present, add
KERNEL_CLASS='App\Kernel'
to your.env.test
file - Open previous settings (File | Settings | Languages & Frameworks | PHP | Test Frameworks)
- Check "Default configuration file"
- Set path to
/app/phpunit.xml.dist
See this comment for detailed steps.
@mortona42: I just published this gist with details that might be helpful to you: https://gist.github.com/quentint/265404e9fd9a6ada2893639006c0865b