Skip to content

Fixing phpunit tests on drupal.org for localgov_services (and others) #335

@finnlewis

Description

@finnlewis

Before we finalise the move to drupal.org, we want to make sure the phpunit tests are passing for Drupal 10 (previous major).

On localgov_services we have some interesting test failures, which @tonypaulbarker, @andybroomfield and I were looking at yesterday.

For example, see https://git.drupalcode.org/project/localgov_services/-/jobs/6831419#L80

We seem to be getting some interesting behaviour where /web is being added multiple times to redirections and paths.

See

https://project.pages.drupalcode.org/-/localgov_services/-/jobs/6831419/artifacts/web/sites/simpletest/browser_output/Drupal_Tests_localgov_services_Functional_WorkflowsIntegrationTest-13-46152139.html

Image

It looks like all tests on drupal.org end up running in http://localhost/web/, which is interesting. I couldn't find any documentation about this or if it has implications for how we need to write tests. @andybroomfield suggested that if we need to account for Drupal being installed in a sub-directory, maybe we need to get and set paths with this in mind.

The first test failure was this:

1) Drupal\Tests\localgov_services_navigation\FunctionalJavascript\LandingPageChildrenTest::testServiceLandingPageLink
Behat\Mink\Exception\ExpectationException: The field "edit-localgov-common-tasks-1-uri" value is "/web/foo", but "/foo" expected.
/builds/project/localgov_services/vendor/behat/mink/src/WebAssert.php:888
/builds/project/localgov_services/vendor/behat/mink/src/WebAssert.php:781
/builds/project/localgov_services/web/core/tests/Drupal/Tests/WebAssert.php:991
/builds/project/localgov_services/modules/localgov_services_navigation/tests/src/FunctionalJavascript/LandingPageChildrenTest.php:149
/builds/project/localgov_services/vendor/phpunit/phpunit/src/Framework/TestResult.php:729

@andybroomfield your suggestion to grab the path with $child[2]->toUrl()->toString() worked ! :)

https://git.drupalcode.org/project/localgov_services/-/commit/a917be7cf2c4995e61615a917a5bee131be136ee

So maybe all these test failures are related to Drupal living in a sub-directory of /web on drupal.org and we need to accommodate this in our tests?

Copying @stephen-cox @ekes @millnut @Adnan-cds for info and incase anyone else has intel to share on this front!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions