Skip to content

Fix phpunit SIMPLETEST_BASE_URL / D12 core-tests failures in drupal-core and drupal-contrib - #215

Merged
rfay merged 3 commits into
mainfrom
20260926_rfay_fix_drupal_core_phpunit_base_url
Sep 27, 2026
Merged

rfay merged 3 commits into
mainfrom
20260926_rfay_fix_drupal_core_phpunit_base_url

Conversation

@rfay

@rfay rfay commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fixes Running tests on a ddev-drupal-dev based instance fails due to a missing env variable #211: drupal-core always omits ddev-router, so DDEV never populates DDEV_PRIMARY_URL. amateescu/ddev-drupal-dev's own config.drupal-dev.yaml sets SIMPLETEST_BASE_URL=${DDEV_PRIMARY_URL}, which is therefore always empty, failing every phpunit functional/JS test with "You must provide a SIMPLETEST_BASE_URL environment variable". Root-caused and reproduced live on staging, including the exact SettingSummariesContentTypeTest::testWorkflowSummary test from the issue.
  • Overrides SIMPLETEST_BASE_URL to the web container's own Docker-network hostname (http://web), reachable regardless of routing, via a .ddev/config.zzz-coder-test-env.yaml file named to sort alphabetically after the add-on's own config file so it wins.
  • Also points BROWSERTEST_OUTPUT_BASE_URL at the real Coder proxy URL instead of the container-only http://web, so failed-test debug links are actually clickable from outside the container.
  • drupal-contrib was not affected — its add-on already hardcodes SIMPLETEST_BASE_URL=http://web. No fix needed there, but added CI coverage anyway (see below) since it's the same regression class.
  • Adds a phpunit smoke-test step to both drupal-integration-test.yml and drupal-contrib-integration-test.yml's GH-runner jobs so this doesn't silently regress again.
  • Filed Consolidate drupal-core/drupal-contrib routing onto freeform's router-based dispatch #213 to track the longer-term fix: switching drupal-core/drupal-contrib to the router-based Host-header dispatch freeform already uses, which avoids this whole class of bug rather than patching around it.
  • Update: the new drupal-contrib CI step above caught a second, unrelated bug: the Contrib skipto D12 (plain, GH) cell failed CI with Cannot open bootstrap script core/tests/bootstrap.php. Root cause: drupal_version=12 installs drupal/core from the 12.x-dev branch (no stable D12 tag exists yet), and Composer's default dist install for a -dev version fetches a GitHub zipball — a git archive snapshot that honors drupal/core's own .gitattributes export-ignore rules, which strip core/tests entirely. D10/D11 are unaffected since they resolve to real tagged releases packaged differently. Fixed by forcing composer config preferred-install.drupal/core source (a real git clone, which doesn't apply export-ignore) for drupal_version=12 only. Verified end-to-end on a fresh workspace (see manual testing below). Filed drupal-contrib D12: core/tests missing because dev-branch dist zip strips it via .gitattributes export-ignore #216 for traceability.

Manual testing instructions

These were run against staging-coder.ddev.com before opening this PR; repeating them here for review/reproduction.

drupal-core

  1. Push this branch as an inactive template version:
    coder templates push drupal-core --directory drupal-core --activate=false \
      --name pr-verify-core --yes \
      --variable image_version="$(cat VERSION)" \
      --variable workspace_image_registry=index.docker.io/ddev/coder-ddev
    
  2. Create a workspace from it:
    coder create verify-core --template drupal-core --template-version pr-verify-core \
      --parameter install_profile=minimal --parameter drupal_version=12 \
      --use-parameter-defaults --yes
    
  3. Wait for setup to finish: ssh verify-core.coder 'tail -f /tmp/drupal-setup.log' until you see the admin credentials block.
  4. Confirm the env override took effect:
    ssh verify-core.coder 'cd ~/drupal-core && ddev exec printenv | grep -i "SIMPLETEST_BASE_URL\|BROWSERTEST_OUTPUT_BASE_URL"'
    
    Expect SIMPLETEST_BASE_URL=http://web and BROWSERTEST_OUTPUT_BASE_URL=https://drupal-site--verify-core--<you>.<coder-domain>.
  5. Run a plain functional test:
    ssh verify-core.coder 'cd ~/drupal-core && ddev phpunit --filter testTitle core/modules/system/tests/src/Functional/System/PageTitleTest.php'
    
    Expect OK.
  6. Run the exact JS test from the issue report:
    ssh verify-core.coder 'cd ~/drupal-core && ddev phpunit --filter testWorkflowSummary core/modules/node/tests/src/FunctionalJavascript/SettingSummariesContentTypeTest.php'
    
    Expect OK.
  7. Clean up: coder delete verify-core --yes && coder templates versions archive drupal-core pr-verify-core --yes.

drupal-contrib (regression check — should already pass, confirming CI coverage doesn't break it)

  1. Push this branch's drupal-contrib template (unchanged by this PR, but push it fresh so CI's new step is exercised against the current code):
    coder templates push drupal-contrib --directory drupal-contrib --activate=false \
      --name pr-verify-contrib --yes \
      --variable image_version="$(cat VERSION)" \
      --variable workspace_image_registry=index.docker.io/ddev/coder-ddev
    
  2. Create a workspace for a small module (pathauto):
    coder create verify-contrib --template drupal-contrib --template-version pr-verify-contrib \
      --parameter project_name=pathauto --parameter project_type=module \
      --parameter drupal_version=11 --parameter install_profile=minimal \
      --use-parameter-defaults --yes
    
  3. Wait for setup: ssh verify-contrib.coder 'tail -f /tmp/drupal-setup.log' until it finishes.
  4. Confirm SIMPLETEST_BASE_URL is already correct (no change expected here):
    ssh verify-contrib.coder 'cd ~/pathauto && ddev exec printenv | grep -i SIMPLETEST_BASE_URL'
    
    Expect SIMPLETEST_BASE_URL=http://web.
  5. Run the same project-agnostic core smoke test the new CI step uses:
    ssh verify-contrib.coder 'cd ~/pathauto && ddev phpunit --filter testTitle web/core/modules/system/tests/src/Functional/System/PageTitleTest.php'
    
    Expect OK.
  6. Run a module-specific functional test for good measure:
    ssh verify-contrib.coder 'cd ~/pathauto && ddev phpunit tests/src/Functional/PathautoUserWebTest.php'
    
    Expect OK.
  7. Clean up: coder delete verify-contrib --yes && coder templates versions archive drupal-contrib pr-verify-contrib --yes.

drupal-contrib D12 (the actual regression this PR fixes — #216)

  1. Create a second workspace from the same pr-verify-contrib template version, this time for skipto on D12 (the exact cell that failed CI):
    coder create verify-contrib-d12 --template drupal-contrib --template-version pr-verify-contrib \
      --parameter project_name=skipto --parameter project_type=module \
      --parameter drupal_version=12 --parameter install_profile=minimal \
      --use-parameter-defaults --yes
    
  2. Wait for setup: ssh verify-contrib-d12.coder 'tail -f /tmp/drupal-setup.log' until it finishes.
  3. Confirm core/tests is present (previously missing before this fix):
    ssh verify-contrib-d12.coder 'cd ~/skipto && test -d web/core/tests && echo EXISTS || echo MISSING'
    
    Expect EXISTS.
  4. Run the same core smoke test the CI step uses:
    ssh verify-contrib-d12.coder 'cd ~/skipto && ddev phpunit --filter testTitle web/core/modules/system/tests/src/Functional/System/PageTitleTest.php'
    
    Expect OK.
  5. Clean up: coder delete verify-contrib-d12 --yes.

Test plan

  • terraform fmt -recursive clean
  • make validate passes for all templates
  • make test-templates passes for all templates
  • Manual verification above run against staging-coder.ddev.com for both templates (see PR description)
  • New CI steps added to drupal-integration-test.yml and drupal-contrib-integration-test.yml will exercise this automatically going forward

🤖 Generated with Claude Code

drupal-core always omits ddev-router, so DDEV never populates
DDEV_PRIMARY_URL. amateescu/ddev-drupal-dev's own config.drupal-dev.yaml
sets SIMPLETEST_BASE_URL=${DDEV_PRIMARY_URL}, which is therefore always
empty, failing every phpunit functional/JS test with "You must provide
a SIMPLETEST_BASE_URL environment variable". Reproduced live on a
staging workspace, including the exact
SettingSummariesContentTypeTest::testWorkflowSummary test from the
issue report.

Override SIMPLETEST_BASE_URL to the web container's own Docker-network
hostname (http://web), which is reachable regardless of routing, via a
config.zzz-coder-test-env.yaml file named to sort after the add-on's
own config file so it wins. Also point BROWSERTEST_OUTPUT_BASE_URL at
the real Coder proxy URL instead of the container-only http://web, so
failed-test debug links are actually clickable from outside.

drupal-contrib is unaffected: its ddev-drupal-contrib add-on already
hardcodes SIMPLETEST_BASE_URL=http://web rather than relying on
DDEV_PRIMARY_URL.

Add a phpunit smoke-test step to both drupal-integration-test.yml and
drupal-contrib-integration-test.yml's GH-runner jobs so this class of
regression is caught in CI going forward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-27 00:43 UTC

…#216

The new phpunit CI step added earlier in this branch failed on the
"Contrib skipto D12 (plain, GH)" cell with "Cannot open bootstrap
script core/tests/bootstrap.php":
https://github.com/ddev/coder-ddev/actions/runs/36280470996/job/108511195288

drupal_version=12 has no stable tag yet, so it resolves to the
12.x-dev branch (see #212). Composer's default dist install for a
-dev/branch version fetches a GitHub zipball, which is a git-archive
snapshot honoring drupal/core's own .gitattributes export-ignore
rules -- and those strip core/tests entirely. D10/D11 are unaffected
since they resolve to real tagged releases, whose dist packages
aren't built this way.

Verified: a plain `git clone` of the same ref includes tests/, and
forcing `composer config preferred-install.drupal/core source` (so
Composer does a real clone instead of downloading the zipball) fixes
it end-to-end -- confirmed core/tests present and the CI smoke test
(`ddev phpunit web/core/modules/system/tests/src/Functional/System/PageTitleTest.php`)
passing on a fresh workspace.

Set that config only for drupal_version=12, before `ddev poser` runs;
D10/D11 are untouched since forcing source there would only slow
down every install for no benefit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rfay rfay changed the title Fix phpunit SIMPLETEST_BASE_URL failures in drupal-core Fix phpunit SIMPLETEST_BASE_URL / D12 core-tests failures in drupal-core and drupal-contrib Sep 27, 2026
Confirmed with the user: D12 is already meant to track HEAD of
drupal/core's main branch, matching how people actually work on D12
issues locally. The "12.x-dev" constraint achieves this indirectly --
it's not a branch name but the version composer's branch-alias maps
main onto -- which was non-obvious enough to be worth spelling out.

No behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rfay
rfay merged commit 4709a56 into main Sep 27, 2026
18 checks passed
@rfay
rfay deleted the 20260926_rfay_fix_drupal_core_phpunit_base_url branch September 27, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running tests on a ddev-drupal-dev based instance fails due to a missing env variable

1 participant