Skip to content

Conversation

@finnlewis
Copy link
Member

@finnlewis finnlewis commented Nov 5, 2025

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
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
Copy link
Member Author

finnlewis commented Nov 7, 2025

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
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
Member Author

@danchamp any ideas with this?

@danchamp
Copy link

@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
Member Author

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

@millnut
Copy link
Member

millnut commented Nov 14, 2025

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

@millnut
Copy link
Member

millnut commented Nov 16, 2025

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
Copy link
Member

willguv commented Jan 8, 2026

@finnlewis to move this to Drupal.org

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.

5 participants