Problem/Motivation
I was running some tests in a Drupal 11.0.10 instance (DDEV, PHP 8.3):
$ ./vendor/bin/phpunit -c web/core/phpunit.xml ./web/core/modules/system/tests/src/Functional/Routing/RouterTest.php
and I am hitting this error:
daniel@drupal:/var/www/html$ ./vendor/bin/phpunit -c web/core/phpunit.xml ./web/core/modules/system/tests/src/Functional/Routing/RouterTest.php
PHPUnit 10.5.45 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.14
Configuration: /var/www/html/web/core/phpunit.xml
E............. 14 / 14 (100%)
HTML output was generated.
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-255-28550090.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-256-10338684.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-257-10338684.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-258-10338684.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-259-10338684.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-260-49606092.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-261-49606092.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-262-45676727.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-263-76088657.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-264-24547444.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-265-12070873.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-266-43380184.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-267-43380184.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-268-43380184.html
....
dev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-274-43380184.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-275-43380184.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-276-43380184.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-277-43380184.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-278-33436292.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-279-79848419.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-280-79848419.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-281-79848419.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-282-79848419.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-283-24906904.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-284-69988493.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-285-69988493.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-286-69988493.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-287-69988493.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-288-69988493.html
http://drupal.11.0.10.ddev.site/sites/simpletest/browser_output/Drupal_Tests_system_Functional_Routing_RouterTest-289-69988493.html
Time: 00:45.135, Memory: 6.00 MB
There was 1 error:
1) Drupal\Tests\system\Functional\Routing\RouterTest::testFinishResponseSubscriber
TypeError: strcasecmp(): Argument #1 ($string1) must be of type string, null given
/var/www/html/web/core/modules/system/tests/src/Functional/Routing/RouterTest.php:49
ERRORS!
Tests: 14, Assertions: 75, Errors: 1.
Screenshot:

Steps to reproduce
1. Install latest Drupal 11 release, or make sure your current D11 has phpunit installed.
2. From the directory where the ./vendor directory is located, run:
./vendor/bin/phpunit -c web/core/phpunit.xml ./web/core/modules/system/tests/src/Functional/Routing/RouterTest.php
You'll see the error mentioned above
Proposed resolution
If you take a look at this snippet from RouterTest.php (lines 49-51):
if (strcasecmp($session->getResponseHeader('vary'), 'accept-encoding') !== 0) {
$this->assertSession()->responseHeaderDoesNotExist('Vary');
}
You can add a small validation to check if $session->getResponseHeader('vary') is empty or not before calling strcasecmp(), something like this:
if (strcasecmp($session->getResponseHeader('vary') ?? "", 'accept-encoding') !== 0) {
$this->assertSession()->responseHeaderDoesNotExist('Vary');
}
After that the tests passed:

But the main question is: Are the tests expecting the Vary header from FinishResponseSubscriber to have a value? I am not sure about that.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| routertest_success.png | 131.17 KB | danrod | |
| routertest_error.png | 88.38 KB | danrod |
Issue fork drupal-3514830
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:
- 3514830-typeerror-strcasecmp-error
changes, plain diff MR !11576
Comments
Comment #3
danrodI created a MR for the workaround, needs review.
Open to any suggestions or feel free to close this if this was addressed before.
Comment #4
danrodComment #5
danrodComment #6
smustgrave commentedSo I believe this may be a local issue, this test passes inside gitlab and to my knowledge doesn't even have random failures around it.
Comment #7
danrodThanks @smustgrave , I'll check in other instances and verify this.
Comment #8
smustgrave commentedCan this one be closed out as the test still passes inside other pipelines
Comment #9
danrod@smustgrave you can close this, please, thanks !
Comment #11
smustgrave commentedThanks for following up!