From a9ceab6865bfd847559b478286b3f4958f41bacd Mon Sep 17 00:00:00 2001 From: jmf3658 Date: Fri, 28 Feb 2025 13:44:25 -0700 Subject: [PATCH 1/4] Add tooling for local development with Lando (#34) --- .lando.yml | 69 ++++++++++++++++++++++++++++++++++++++++++++++ .lando/phpunit.xml | 0 .lando/test.sh | 11 ++++++++ README.md | 19 +++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 .lando.yml create mode 100644 .lando/phpunit.xml create mode 100644 .lando/test.sh diff --git a/.lando.yml b/.lando.yml new file mode 100644 index 0000000..077e32a --- /dev/null +++ b/.lando.yml @@ -0,0 +1,69 @@ +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: + 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 \ No newline at end of file diff --git a/.lando/phpunit.xml b/.lando/phpunit.xml new file mode 100644 index 0000000..e69de29 diff --git a/.lando/test.sh b/.lando/test.sh new file mode 100644 index 0000000..d62e37e --- /dev/null +++ b/.lando/test.sh @@ -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-pinned" +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 --display-deprecations --testdox $1 \ No newline at end of file diff --git a/README.md b/README.md index 69d22fa..29504bc 100644 --- a/README.md +++ b/README.md @@ -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 +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 From b7fb162cd1e9e8340af67cdfe99286b77d74ee6a Mon Sep 17 00:00:00 2001 From: jmf3658 Date: Fri, 28 Feb 2025 13:45:41 -0700 Subject: [PATCH 2/4] Add contents of phpunit.xml file --- .lando/phpunit.xml | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.lando/phpunit.xml b/.lando/phpunit.xml index e69de29..22de0b5 100644 --- a/.lando/phpunit.xml +++ b/.lando/phpunit.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + ./tests/TestSuites/UnitTestSuite.php + + + ./tests/TestSuites/KernelTestSuite.php + + + ./tests/TestSuites/FunctionalTestSuite.php + + + ./tests/TestSuites/FunctionalJavascriptTestSuite.php + + + ./tests/TestSuites/BuildTestSuite.php + + + + + ./includes + ./lib + ./modules + ../modules + ../sites + + + ./modules/*/src/Tests + ./modules/*/tests + ../modules/*/src/Tests + ../modules/*/tests + ../modules/*/*/src/Tests + ../modules/*/*/tests + ./lib/** + ./modules/** + ../modules/** + + + \ No newline at end of file From 49f7a256f4e9584a5ac13a384ab79cfbb3f67127 Mon Sep 17 00:00:00 2001 From: Mark Fullmer Date: Thu, 24 Apr 2025 08:48:13 -0700 Subject: [PATCH 3/4] Update test.sh --- .lando/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lando/test.sh b/.lando/test.sh index d62e37e..d82b9a8 100644 --- a/.lando/test.sh +++ b/.lando/test.sh @@ -3,9 +3,9 @@ # 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-pinned" + 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 --display-deprecations --testdox $1 \ No newline at end of file +/app/vendor/bin/phpunit -c /app/.lando/phpunit.xml --stop-on-failure --display-deprecations --testdox $1 From ae484a3a0463eebbc9f42ed1a22f19c155ed0b0d Mon Sep 17 00:00:00 2001 From: jmf3658 Date: Fri, 29 Aug 2025 13:31:27 -0500 Subject: [PATCH 4/4] Minor updates to improve Lando tooling --- .lando.yml | 3 ++- .lando/test.sh | 2 +- composer.json | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.lando.yml b/.lando.yml index 077e32a..74402e1 100644 --- a/.lando.yml +++ b/.lando.yml @@ -20,6 +20,7 @@ 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 @@ -66,4 +67,4 @@ tooling: - sh .lando/test.sh drush: service: appserver - cmd: drush --root=/app --uri=https://drupal-core-development-project.lndo.site \ No newline at end of file + cmd: drush --root=/app --uri=https://drupal-core-development-project.lndo.site diff --git a/.lando/test.sh b/.lando/test.sh index d82b9a8..1fc6ef4 100644 --- a/.lando/test.sh +++ b/.lando/test.sh @@ -8,4 +8,4 @@ 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 --display-deprecations --testdox $1 +/app/vendor/bin/phpunit -c /app/.lando/phpunit.xml --stop-on-failure --stop-on-error --display-deprecations --testdox $1 diff --git a/composer.json b/composer.json index 13fcd29..a2fbe50 100644 --- a/composer.json +++ b/composer.json @@ -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": "*" @@ -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": {