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.

Comments

star-szr’s picture

Issue tags: +rc eligible

Since this is just changing tests it could be committed during RC if we get a patch here.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

Issue tags: -rc eligible

@martin107 could you post a starter patch from your interdiff in the other issue?

martin107’s picture

Assigned: Unassigned » martin107
Issue summary: View changes

I will take a look ... it was so long ago that I posted this .. sorry it slipped off my todo list.

From a cursory glance I see IntrospectableContainers are now deprecated -- so the solution may differ....

IS change.
I could not spell cascaded.

joelpittet’s picture

@martin107 Thanks, I know the feeling, just cleaning the theme queue and spotting the ones like this. Improvements to the tests should be ok get in 8.3.x for sure and if this is a bug 8.2.x also has a shot.

martin107’s picture

Assigned: martin107 » Unassigned

Ah thanks for prodding me ...

A few comments

ThemeTestSubscriber does not appear in on the webtest interface ( /admin/config/development/testing )

It doesn't appear on the test output generated by testbot ( for example https://www.drupal.org/pift-ci-job/477903 )

The service named 'theme_test.subscriber' that uses the class in its definition but is never ever used!

Running the test from the console

sudo php \
./core/scripts/run-tests.sh --color \
--die-on-fail \
--url http://dev.drupal.co.uk \
--verbose \
--class 'Drupal\theme_test\EventSubscriber\ThemeTestSubscriber'

where dev.drupa.co.uk is the name of my dummy installation - show that the construct() definition has a unrelated flaw.

So the class as a whole looks broken or is redundant.

I am afraid I am not too familiar with the theme test strategy which looks extensive.

Is the reason for the test still relevant ? .. if so I want to change this issue to resurrecting a wanted zombified test?

or can the code and service definition simply be deleted because other tests provide the necessary cover?

mile23’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

@joelpittet asked me to look, so:

Of course it doesn't run. It's not a test. :-) It's a fixture. It first shows up in #2247991: [May 27] Move all module code from …/lib/Drupal/… to …/src/… for PSR-4 though it looks like that's a giant patch that didn't mark the file as moved, and instead created it. No doubt it has a real history preceding that.

It's part of the theme_test module, which is installed for tests like EngineNyanCatTest. Yes, that's a real core test. :-)

It looks like the event listener part is used by ThemeEarlyInitializationTest, and maybe others.

Marking this as postponed because I'm not sure whether there's still a bug or whether this explanation makes it go away. @martin107 can you check it out and see if it's still relevant?

martin107’s picture

Assigned: Unassigned » martin107
Status: Postponed (maintainer needs more info) » Active

EngineNyanCatTest and ThemeEarlyInitializationTest

Ah that is really valuable information... it gets me over a hump in analysis.

Mile23++

@martin107 could you post a starter patch

That looks more possible :)

As far as I can see as the fixture/module is enabled ThemeTestSubscriber::container is still used in the class but not set.

So it is A or B

A) Functionality has been reduced. and we need to restore it.

B) The fixture can be slimmed down to only things that are useful to testing core code.

I will find time next week to look at this some more.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
catch’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Issue tags: +Bug Smash Initiative

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.

mstrelan’s picture

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

Can we close this now that the referenced issue is in?

acbramley’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Absolutely, added credits for people who worked on this.