Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

Serve Drupal from a /subdir to mimic drupal.org testing.#232

Draft
finnlewis wants to merge 2 commits into
3.xfrom
feature/231-ddev-subdirectory
Draft

Serve Drupal from a /subdir to mimic drupal.org testing.#232
finnlewis wants to merge 2 commits into
3.xfrom
feature/231-ddev-subdirectory

Conversation

@finnlewis

@finnlewis finnlewis commented Nov 5, 2025

Copy link
Copy Markdown
Member

Work in progress...

The motivation here is to be able to run tests against the site installed under a dub-directory.

drupal.org does this, which is exposing issues in our tests and bugs in some places (eg. localgovdrupal/localgov_services#335)

It would be great to be able to run the tests locally to replicate this.

The setup on this merge request serves the site at /subdir

@finnlewis finnlewis marked this pull request as draft November 5, 2025 15:56
@finnlewis

Copy link
Copy Markdown
Member Author

Currently the tests do not work within the web container.

I am wondering if there's a difference in how the phpunit tests run with respect to the /subdir

@ekes @stephen-cox @tonypaulbarker any ideas?

@finnlewis

finnlewis commented Nov 7, 2025

Copy link
Copy Markdown
Member Author

Steps to test this:

git clone git@github.com:localgovdrupal/localgov_project.git MY_PROJECT
cd MY_PROJECT
git checkout feature/231-ddev-subdirectory
ddev start
ddev composer install
ddev drush si localgov -y
ddev drush en localgov_demo -y
ddev drush uli
ddev phpunit web/modules/contrib/localgov_services/tests/src/Functional/PagesIntegrationTest.php --filter=testPostLink   

Result


Testing Drupal\Tests\localgov_services\Functional\PagesIntegrationTest
F                                                                   1 / 1 (100%)

Time: 00:13.986, Memory: 12.63 MB

There was 1 failure:

1) Drupal\Tests\localgov_services\Functional\PagesIntegrationTest::testPostLink
User xn0qcuzb successfully logged in.
Failed asserting that false is true.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:56
/var/www/html/web/core/tests/Drupal/Tests/UiHelperTrait.php:182
/var/www/html/web/modules/contrib/localgov_services/tests/src/Functional/PagesIntegrationTest.php:86
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:729

FAILURES!
Tests: 1, Assertions: 6, Failures: 1.

HTML output was generated
https://localgov.ddev.site/subdir/sites/simpletest/browser_output/Drupal_Tests_localgov_services_Functional_PagesIntegrationTest-1-99371730.html
Failed to run phpunit web/modules/contrib/localgov_services/tests/src/Functional/PagesIntegrationTest.php --filter=testPostLink: exit status 1

Clicking on the HTML output, we can see that the /subdir is being used, but 'Home' link does not link to /subdir

image

So is there some other configuration that phpunit needs, to know it is running in a sub-directory?

@finnlewis

Copy link
Copy Markdown
Member Author
ddev ssh
curl http://web/subdir/user/reset/2/1762535342/1CzaYiUIzHIt9XvOUTzmBrT25xlS-LltcvC3fLj_bQ4/login?destination=user/2

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8" />
<link rel="canonical" href="http://web/subdir/" />
<meta name="robots" content="noindex" />
<link rel="shortlink" href="http://web/subdir/" />
<meta name="Generator" content="Drupal 10 (LocalGov Drupal | https://localgovdrupal.org)" />
<meta name="MobileOptimized" content="width" />
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/subdir/core/misc/favicon.ico" type="image/vnd.microsoft.icon" />

    <title>Access denied | Drush Site-Install</title>
    <link rel="stylesheet" media="all" href="/subdir/sites/default/files/css/css_htSKMKNfOhzDZ5qM6hmy6kHsxzOX0fwAxDcvTNmxZf8.css?delta=0&amp;language=en&amp;theme=localgov_scarfolk&amp;include=eJxtylEOwjAMA9ALrexIU7K5pSJtpqRl4vYw8TFU8Wf7OWptdMC1YI5Xvh3gs_okupIkfS4ksLYw1Qqbf8t1YXJ8KfwlNtC2Wi_sg0S1EmCmNkoSZZJhLKg9FMp12HdKCC03QeCPPAbude8s2e_YAqfJX95Q5pPed25myA" />
<link rel="stylesheet" media="all" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css" />
<link rel="stylesheet" media="all" href="/subdir/sites/default/files/css/css_Kw50QK_vMtk6MGpmjCxWfBnrOdHoAQUCHRoZxkBaBo8.css?delta=2&amp;language=en&amp;theme=localgov_scarfolk&amp;include=eJxtylEOwjAMA9ALrexIU7K5pSJtpqRl4vYw8TFU8Wf7OWptdMC1YI5Xvh3gs_okupIkfS4ksLYw1Qqbf8t1YXJ8KfwlNtC2Wi_sg0S1EmCmNkoSZZJhLKg9FMp12HdKCC03QeCPPAbude8s2e_YAqfJX95Q5pPed25myA" />
<link rel="stylesheet" media="print" href="/subdir/sites/default/files/css/css_LZzXF3JfwVtx-faUMFgHW-Hnf1VvWyXKVyKCcavDuvo.css?delta=3&amp;language=en&amp;theme=localgov_scarfolk&amp;include=eJxtylEOwjAMA9ALrexIU7K5pSJtpqRl4vYw8TFU8Wf7OWptdMC1YI5Xvh3gs_okupIkfS4ksLYw1Qqbf8t1YXJ8KfwlNtC2Wi_sg0S1EmCmNkoSZZJhLKg9FMp12HdKCC03QeCPPAbude8s2e_YAqfJX95Q5pPed25myA" />
<link rel="stylesheet" media="all" href="/subdir/sites/default/files/css/css_ZLAFL4ExOiyJKM0NapRWK2dckR5SFuvGdS18l2yotSo.css?delta=4&amp;language=en&amp;theme=localgov_scarfolk&amp;include=eJxtylEOwjAMA9ALrexIU7K5pSJtpqRl4vYw8TFU8Wf7OWptdMC1YI5Xvh3gs_okupIkfS4ksLYw1Qqbf8t1YXJ8KfwlNtC2Wi_sg0S1EmCmNkoSZZJhLKg9FMp12HdKCC03QeCPPAbude8s2e_YAqfJX95Q5pPed25myA" />

@finnlewis

Copy link
Copy Markdown
Member Author

@danchamp any ideas with this?

@danchamp

Copy link
Copy Markdown

@danchamp any ideas with this?

@finnlewis I'm a Lando user so will take a look at what changes are needed to test this locally.

@finnlewis

Copy link
Copy Markdown
Member Author

@millnut is this something you might have any bright ideas about?

@millnut

millnut commented Nov 14, 2025

Copy link
Copy Markdown
Member

Yep I'll take a look @finnlewis just finishing an alpha version of a LocalGov Drupal recipe installer.

@millnut

millnut commented Nov 16, 2025

Copy link
Copy Markdown
Member

Hi @finnlewis so that error is actually misleading as you're not actually logged in as a cookie isn't set in the header, see https://www.drupal.org/project/drupal/issues/3556139 for an update to core to make the message more clear.

So it looks like a cookie issue or nginx rewrite issue.

@willguv

willguv commented Jan 8, 2026

Copy link
Copy Markdown
Member

@finnlewis to move this to Drupal.org

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants