11

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.

18

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

5

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">
</listener>

Not sure if this will cause any issues.

6
  • Thanks @albertski this worked for me but don't know why yet... 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
  • 3
    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
  • 1
    "Do we need this screw?" "Nahhhh"
    – AlxVallejo
    Apr 15 '20 at 19:31
4

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.

1
  • If you are doing things in Drupal, I think this is the answer you are looking for. And you probably want to put it in the require-dev section of composer.json: "require-dev": { "drupal/core-dev": "^9" },
    – rjpeter2
    Jan 6 at 23:47

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.