When I try to run a unit test I get an error that SymfonyTestsListener does not exist. Am I running this correctly?

../../vendor/bin/phpunit -c phpunit.xml ../modules/custom/my_module/

Class "Symfony\Bridge\PhpUnit\SymfonyTestsListener" does not exist

I am using PHPUnit 6.5.13.


Had a similar issue: Solved it by adding the "symfony/phpunit-bridge": "^3.4.3" library.

| improve this answer | |

Removing the line below in phpunit.xml fixes my issue:

<!-- The Symfony deprecation listener has to come after the Drupal listener -->
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">

Not sure if this will cause any issues.

| improve this answer | |
  • Thanks @albertski this worked for me but don't know why yet... – Beto Aveiga Dec 28 '18 at 21:26
  • Where to comment this? is this line not really required? – ARUN Jan 21 '19 at 8:25
  • This is in phpunit.xml. – albertski Jan 21 '19 at 15:57
  • @ARUN, I needed to modify [web/]core/phpunit.xml.dist. – andileco Jan 28 '19 at 23:34
  • 2
    Removing this line will only disable the deprecation listener, the correct answer here is provided by @dragu-alexandru. – mpp May 20 '19 at 15:02

Although the approved answer here shows the exact package that is needed what users may be looking for is to require the "drupal/core-dev" package which contains the needed "symfony/phpunit-bridge" as a dependency.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.