Unreached test code in ThemeTestSubscriber

Created on 4 April 2014, almost 11 years ago
Updated 5 March 2025, 2 days ago

ThemeTestSubscriber

Consistently using ContainerAwareTrait in core has unveiled 3 cascaded bugs hiding each other from detection see

https://drupal.org/comment/8643347#comment-8643347 (2)

The relevant extract :-

(1) ThemeTestSubscriber extends ContainerAware it does not need a service_container it needs an IntrospectableContainer.

(2) In any event theme_test.services.yml does not as expected inject a container of any form.

(3) The place where the uninitialised container is used is "unreached code" by the testbot hence no bug is picked up!

That issue, is limited in scope, and so has just left the stub of a fix as the @todo in the ThemeTestSubscriber.

This issue is to ensure

1) The mocked container is initialised
2) The unreached code is actually used.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

theme system

Created by

🇬🇧United Kingdom martin107

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    So this code was introduced in #1886448: Rewrite the theme registry into a proper service , swapped from _theme_registry_callback and _theme_test_load_registry which just did a print.

    I grepped for the string "registry initialized" which is checked in \Drupal\Tests\system\Functional\Theme\FastTest

    Debugging that test, ThemeTestSubscriber::onView is never hit. This is because MainContentViewSubscriber::onViewRenderArray runs before it and calls setResponse which stops propagation.

    Increasing the priority of ::onView to 10 will cause it to run BUT exposes even more issues with the test.

    1. the test hits user/autocomplete which is not an autocomplete path, it's a user path. The test hits a 404 page
    2. The test checks the response contains the account name, which it does, but not in any markup.
    3. The test checks for the absence of the "registry initialized" text, which I don't think would even happen if everything was working as expected because the event subscriber throws an exception, it doesn't print anything.

Production build 0.71.5 2024