Problem/Motivation

When setting up testing on a Drupal installation it's pretty easy to accicentally enter an invalid value in phpunit.xml. One fault i've seen happen quite a few times is entering the database uri that is support to go in SIMPLETEST_DB into the wrong variable SIMPLETEST_BASE_URL.

The problem is this results in a segmentation fault while running tests, which really is not helpfull. Unless you have seen this before resolving this is quite a timesink. I'm not sure if this only happened with apache-php, but it might.

Output you see:

PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\wordproof\Kernel\TimestampRepositoryTest
ERESegmentation fault

Steps to reproduce

Enter the datbase dsn (mysql://username:password/...) into the SIMPLETEST_BASE_URL env variable or phpunit.xml. This will result in a segementation fault.

Proposed resolution

Add a validation of the scheme of the base url. We parse the url anyways, so there is little overhead to check for http(s).

Issue fork drupal-3217374

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bbrala created an issue. See original summary.

bbrala’s picture

Version: 9.0.x-dev » 9.3.x-dev
bbrala’s picture

Something interesting about this is that the run-tests.sh actually does add either http or https. Perhaps the only place it needs fixing is the FunctionalTestSetupTrait.php.

daffie’s picture

Status: Active » Needs work
Issue tags: +Needs tests

@bbrala: Thank you for the bug report and the MR. To get committed the change in the MR also needs an automated test. I think that the test can best be added to the test class Drupal\FunctionalTests\BrowserTestBaseTest. Set the variable with the command putenv("SIMPLETEST_BASE_URL=somewrongurl"); and then set the expected exception with $this->expectDeprecation() and as last call the method $this->setupBaseUrl().

bbrala’s picture

Ah, i was wondering how i would test this, i'll have a look, thanks for the suggestion.

daffie’s picture

Issue tags: -Needs tests

The testbot is not happy with the extra empty line.

bbrala’s picture

Everything should be resolved now :)

bbrala’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
The bugfix has testing.
For me it is RTBC.

  • catch committed 883787e on 9.3.x
    Issue #3217374 by bbrala, daffie: SIMPLETEST_BASE_URL does not validate...

  • catch committed 476951f on 9.2.x
    Issue #3217374 by bbrala, daffie: SIMPLETEST_BASE_URL does not validate...
catch’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.