Open gitressa opened 2 years ago
I'd also like to know how to use sqlite for PhpUnit tests when connected directly to the container.
By "directly to the container" - I am using VSCode's "Dev container" extension to connect directly to the Lando app container.
For example, with the following in my phpunit.xml file:
<env name="SIMPLETEST_DB" value="sqlite://localhost/tmp/db.sqlite"/>
when running a test, I get a Failed to run installer database tasks: Failed to connect to your database server.
error. I've also tried
<env name="SIMPLETEST_DB" value="sqlite://appserver/tmp/db.sqlite"/>
and
<env name="SIMPLETEST_DB" value="sqlite://database/tmp/db.sqlite"/>
with the same result.
If I try to connect to mysql, I get a similar result:
<env name="SIMPLETEST_DB" value="mysql://drupal10:drupal10@database/drupal10#phpunit"/>
What am I missing?
thanks, -mike
If it's any help, Lando + Drupal Contributions uses SQLite like this in .lando.yml
:
SIMPLETEST_DB: "sqlite://localhost/tmp/db.sqlite"
(Note: Add this patch for Drupal 10 compatibility: https://github.com/lando/drupal-contributions/pull/76)
Using VSCode's "Dev container" extension to connect directly to the Lando app container sounds interesting. It would be cool to also get PhpStorm and Lando + Drupal Contributions working that way.
If it's relevant, there's a Free PhpStorm license for +35 Drupal issue credits over the past year, and you seem to qualify.
@gitressa Thanks for the info -
I'm not sure what I was doing wrong yesterday, but I tried things again today and it worked (for mysql and sqlite) - very odd.
I didn't add anything to my .lando.yml file. The values I'm using in my phpunit.xml file are:
<env name="SIMPLETEST_BASE_URL" value="http://sitename.lndo.site"/>
<env name="SIMPLETEST_DB" value="mysql://drupal10:drupal10@database/drupal10#phpunit"/>
or
<env name="SIMPLETEST_BASE_URL" value="http://sitename.lndo.site"/>
<env name="SIMPLETEST_DB" value="sqlite://localhost/tmp/db.sqlite"/>
I'm all set with a PhpStorm license, but thanks for the info.
-mike
Great that you got it working. Sometimes all it takes is a restart :)
And thanks by the way for blogging about PhpStorm in Setting up Xdebug with Lando and PhpStorm in 2018. It was quite helpful when I recently had to set it up myself.
Since then (as you probably know) things have luckily changed and most of the configuration happens automagically. So I updated the documentation for Configuring PhpStorm and Xdebug in Lando for Drupal 10 the other day, in case you're interested. Have a great day
Yep, I'm well aware - I teach with various combinations of PhpStorm/VSCode + Lando/DDEV, including setting up all the things (PhpUnit, PhpStan, phpcs, Xdebug) integrated with the IDE.
I'm working on adding connecting both PhpStorm and VSCode directly to the Lando/DDEV app/web container with all the same tools integrated in the IDE.
thanks again! -mike
Great! I hope you get it all working, adding PHPUnit to the mix adds a little extra challenge :)
I now realize that is also what https://github.com/lando/php/issues/6 is about. I'll have a go at it later, and add it to the "Configuring PhpStorm and Xdebug in Lando" for Drupal 10 guide if I succeed.
SQLite is supported out of the box, which is great, and you can run this, without having to define
database: sqlite
in.lando.yml
:$ drush site:install --db-url=sqlite://drupal9:drupal9@database/drupal9 -y
Should SQLite perhaps be added to the list of "Databases" under "Services", together with MariaDB, MongoDB, MySQL, etc. on https://docs.lando.dev/?