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:

Screenshot of error running Core RouterTest tests

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:

Screenshot of RouteTest tests succeded

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

CommentFileSizeAuthor
routertest_success.png131.17 KBdanrod
routertest_error.png88.38 KBdanrod

Issue fork drupal-3514830

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:

Comments

danrod created an issue. See original summary.

danrod’s picture

I created a MR for the workaround, needs review.

Open to any suggestions or feel free to close this if this was addressed before.

danrod’s picture

Status: Active » Needs review
danrod’s picture

Issue tags: +Novice
smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

So 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.

danrod’s picture

Thanks @smustgrave , I'll check in other instances and verify this.

smustgrave’s picture

Can this one be closed out as the test still passes inside other pipelines

danrod’s picture

@smustgrave you can close this, please, thanks !

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Thanks for following up!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.