12

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.

4 Answers 4

19

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... Commented Dec 28, 2018 at 21:26
  • Where to comment this? is this line not really required?
    – Cool
    Commented Jan 21, 2019 at 8:25
  • This is in phpunit.xml.
    – albertski
    Commented Jan 21, 2019 at 15:57
  • 3
    Removing this line will only disable the deprecation listener, the correct answer here is provided by @dragu-alexandru.
    – mpp
    Commented May 20, 2019 at 15:02
  • 1
    "Do we need this screw?" "Nahhhh"
    – AlxVallejo
    Commented Apr 15, 2020 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
    Commented Jan 6, 2022 at 23:47
0

Try using symfony/phpunit-bridge:

composer require --dev symfony/phpunit-bridge

This will install the phpunit-bridge that is used with phpunit, it fixed the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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