Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: drupal-core-development-project
recipe: drupal11
config:
composer_version: 2
webroot: web
# To use XDebug, set the following to `true`, then run `lando rebuild`
# In VS Code, install the extension https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug
# A .vscode/launch.json file needs to be present, along with a php.ini file.
# See https://docs.lando.dev/guides/lando-with-vscode.html
# and https://gist.github.com/MatthieuScarset/0c3860def9ff1f0b84e32f618c740655
xdebug: false
services:
pma:
type: phpmyadmin
hosts:
- database
chrome:
type: compose
services:
image: drupalci/webdriver-chromedriver:production
command: chromedriver --log-path=/tmp/chromedriver.log --no-sandbox --headless --verbose --whitelisted-ips= --allowed-origins=*
appserver:
scanner: false
build:
- mkdir -p $LANDO_WEBROOT/sites/simpletest/browser_output
- cp web/sites/default/default.settings.php web/sites/default/settings.php
- echo '\r\n$databases["default"]["default"] = [
\r\n "database" => "drupal11",
\r\n "username" => "drupal11",
\r\n "password" => "drupal11",
\r\n "prefix" => "",
\r\n "host" => "database",
\r\n "port" => "3306",
\r\n "isolation_level" => "READ COMMITTED",
\r\n "driver" => "mysql",
\r\n "namespace" => "Drupal\\mysql\\Driver\\Database\\mysql",
\r\n "autoload" => "core/modules/mysql/src/Driver/Database/mysql/",
\r\n];' >> web/sites/default/settings.php
- echo '\r\n$settings["hash_salt"] = "1234567890";' >> web/sites/default/settings.php
overrides:
# Changes only take effect after `lando rebuild`
environment:
# See https://agile.coop/blog/drupal-phpunit-tests-lando/
# Based on https://github.com/lando/lando/pull/1092/files
# See also https://github.com/lando/lando/issues/360
SYMFONY_DEPRECATIONS_HELPER: 'disabled'
SIMPLETEST_DB: 'mysql://drupal11:drupal11@database/drupal11'
BROWSERTEST_OUTPUT_BASE_URL: 'http://drupal-core-development-project.lndo.site'
# Note: SIMPLETEST_BASE_URL must currently be defined in the phpunit.xml file
# --disable-dev-shm-usage is needed to allow iframed content, such
# as Layout Builder iFrame Modals
# --no-sandbox is needed to run. If absent, the message will be
# 'The test wasn't able to connect to your webdriver instance.'
# goog:chromeOptions is new as of Drupal 10.3
# w3c:false is needed per #3240792
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"w3c":false, "args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://chrome:9515"]'
tooling:
composer:
service: appserver
description: Run composer commands
cmd:
- php -d memory_limit=-1 /usr/local/bin/composer
test:
service: appserver
description: Run all PHPUnit tests
cmd:
- sh .lando/test.sh
drush:
service: appserver
cmd: drush --root=/app --uri=https://drupal-core-development-project.lndo.site
60 changes: 60 additions & 0 deletions .lando/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="/app/web/core/tests/bootstrap.php"
colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
cacheResult="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="32767" />
<ini name="memory_limit" value="-1" />
<env name="SIMPLETEST_BASE_URL" value="http://drupal-core-development-project.lndo.site"
force="true" />
</php>
<extensions>
<bootstrap class="Drupal\TestTools\Extension\HtmlLogging\HtmlOutputLogger">
<parameter name="outputDirectory" value="/app/web/sites/simpletest/browser_output" />
<parameter name="verbose" value="true" />
</bootstrap>
</extensions>
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
<testsuite name="build">
<file>./tests/TestSuites/BuildTestSuite.php</file>
</testsuite>
</testsuites>
<source>
<include>
<directory>./includes</directory>
<directory>./lib</directory>
<directory>./modules</directory>
<directory>../modules</directory>
<directory>../sites</directory>
</include>
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
<directory>../modules/*/src/Tests</directory>
<directory>../modules/*/tests</directory>
<directory>../modules/*/*/src/Tests</directory>
<directory>../modules/*/*/tests</directory>
<directory suffix=".api.php">./lib/**</directory>
<directory suffix=".api.php">./modules/**</directory>
<directory suffix=".api.php">../modules/**</directory>
</exclude>
</source>
</phpunit>
11 changes: 11 additions & 0 deletions .lando/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# We need to add drupal/core-dev for PHPUnit
# We do this in a check here so as not to run `composer require`
# every time we want to run tests.
if ! grep -q "drupal/core-dev" composer.json; then
echo "Adding core tooling. This may take a moment...";
composer require "drupal/core-dev"
fi
mkdir -p /app/web/sites/simpletest/browser_output
chmod 777 /app/web/sites/simpletest/browser_output
# Now we actually run the command...
/app/vendor/bin/phpunit -c /app/.lando/phpunit.xml --stop-on-failure --stop-on-error --display-deprecations --testdox $1
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ following changes to the installation instructions for that addon:
To run PHPUnit tests, you will need to tweak the DDEV phpunit command until
https://github.com/justafish/ddev-drupal-core-dev/pull/37 is fixed.

## Usage with Lando
This repository includes tooling for use with [Lando](https://lando.dev/):

```
## Spin up the containers
lando start

## Use drush commands like site:install and user:login
lando drush si -y
lando drush uli

## Add contrib modules
lando composer require drupal/linkit

## Run PHPUnit tests (including FunctionalJavascript!)
## lando test <path/to/test>
lando test web/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php
```

## Installing other packages

You can install any Composer package as you would with a normal project. This
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
],
"require": {
"composer/installers": "^1.9 | ^2",
"drupal/core-composer-scaffold": "*",
"drupal/drupal": "*",
"drupal/core": "*",
"drupal/core-composer-scaffold": "*",
"drupal/core-dev": "*",
"drupal/core-recommended": "*",
"drupal/drupal": "*",
"drush/drush": "^13",
"phpspec/prophecy-phpunit": "*",
"symfony/var-dumper": "*"
Expand All @@ -57,12 +57,14 @@
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
"drupal/core-recipe-unpack": true,
"drupal/core-vendor-hardening": true,
"drupal/core-composer-scaffold": true,
"php-http/discovery": true,
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
"tbachert/spi": true
}
},
"scripts": {
Expand Down