Problem/Motivation

This is a bug report but I'm filing it against 8.4.x because it's not horribly urgent.

Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest looks like this:

[..]
use Symfony\Component\EventDispatcher\Tests\ContainerAwareEventDispatcherTest as SymfonyContainerAwareEventDispatcherTest;
use Symfony\Component\EventDispatcher\Tests\TestEventListener;

/**
 * Unit tests for the ContainerAwareEventDispatcher.
 *
 * NOTE: 98% of this code is a literal copy of Symfony's emerging
 * CompiledEventDispatcherTest.
 *
 * This file does NOT follow Drupal coding standards, so as to simplify future
 * synchronizations.
 *
 * @see https://github.com/symfony/symfony/pull/12521
 *
 * @group EventDispatcher
 */
class ContainerAwareEventDispatcherTest extends SymfonyContainerAwareEventDispatcherTest

If we click through to that pull request: https://github.com/symfony/symfony/pull/12521 we see that it's been closed.

We should not depend on a test from a dependency, because it could move or change expectations.

A comment in #2874909-25: Update Symfony components to 3.3.* references this test.

Proposed resolution

Figure out what to do.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

andypost’s picture

andypost’s picture

Category: Bug report » Task

I don't think it's a bug, the \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest tests exactly core expectations from event listener.
That looks too much binded but let's first resolve #2909185: Replace ContainerAwareEventDispatcher with Symfony EventDispatcher

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikelutz’s picture

Title: ContainerAwareEventDispatcherTest depends on Symfony tests » [Symfony 4] ContainerAwareEventDispatcherTest depends on Symfony tests
Issue tags: +Drupal 9, +Symfony 4
Parent issue: » #2976394: Allow Symfony 4.4 to be installed in Drupal 8
mikelutz’s picture

At a minimum we should base against symfony's AbstractEventDispatcherTest, rather than the ContainerAwareEventDispatcherTest, as ContainerAwareEventDispatcherTest has been removed in Symfony4.

I dug through the logs to get a bit more history here. It looks like we created our own ContainerAwareEventDispatcher from scratch, modeled on symfony's with some improvements, and then had our test class extend Symfony's ContainerAware test class. Half a dozen test function in this class actually test Symfony's ContainerAwareEventDispatcher instead of ours, so they are basically useless. in #2927746: Update Symfony components to 3.4.* We updated symfony to 3.4, and Symfony's ContainerAware dispatcher was deprecated. These half a dozen useless inherited test functions started throwing deprecation errors (because they were testing the wrong dispatcher), so we wrapped them in @expectedDeprecation wrappers to hide them. We really seem to want to use the tests in Symfony's AbstractEventDispatcherTest which does test against the dispatcher we set up in the setUp method, but there is nothing in Symfony's ContainerAwareEventDispatcherTest that we actually use.

So this patch switches from extending ContainerAware to extending the AbstractEventDispatcherTest, and removes the now unneeded Deprecation wrappers. I think this is a good compromise right now, as it will let us continue the Symfony 4 work while #2909185: Replace ContainerAwareEventDispatcher with Symfony EventDispatcher is resolved, and remove useless tests. We still extend off a symfony test, but at least it's an abstract test class that's made to be extended, and is still available in symfony 4.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Very tidy patch and agreed this is a good interim step.

Do we want an additional follow-up other than #2909185: Replace ContainerAwareEventDispatcher with Symfony EventDispatcher to remove the test subclass? That's the only thing I can think of here but it might be fine to just have the one issue open for now. RTBC.

mikelutz’s picture

I haven't completely read through the other thread, but I assume if they deprecate the dispatcher, then they would be forced to mark the whole test subclass as @legacy in the same patch, and it would be removed with all the other deprecations when we open Drupal 9. I don't think we would want to remove the test subclass completely before then, as it has value in continuing to test the deprecated dispatcher for the remainder of Drupal 8.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed e4d88be and pushed to 8.8.x. Thanks!

  • catch committed e4d88be on 8.8.x
    Issue #2895487 by mikelutz, Mile23: [Symfony 4]...
jibran’s picture

Given that this a test fix I'd vote for 8.7.x cherry-pick for the sake of keeping the tests in sync.

mikelutz’s picture

I don't think there would be any issue with backporting. It should be valid in 8.7

Status: Fixed » Closed (fixed)

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

mstrelan’s picture

From what I can tell this works for symfony 4.2 but not 4.3 as AbstractEventDispatcherTest no longer exists.