Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with PHPUnit 11: Interface "PHPUnit\Event\Test\AssertionSucceededSubscriber" not found #735

Open
simbig opened this issue Mar 14, 2025 · 4 comments

Comments

@simbig
Copy link

simbig commented Mar 14, 2025

Description

When attempting to run tests with PHPUnit 11 with the ClockworkExtension mentioned for PHPUnit 10, the tests fail due to a missing interface PHPUnit\Event\Test\AssertionSucceededSubscriber.

The error message is as follows:

There was 1 PHPUnit test runner warning:

1) Bootstrapping of extension Clockwork\Support\Laravel\Tests\ClockworkExtension failed: Interface "PHPUnit\Event\Test\AssertionSucceededSubscriber" not found
#0 /var/www/vendor/phpunit/phpunit/src/Runner/Extension/ExtensionBootstrapper.php(73): Clockwork\Support\Laravel\Tests\ClockworkExtension->bootstrap(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\Extension\Facade), Object(PHPUnit\Runner\Extension\ParameterCollection))
#1 /var/www/vendor/phpunit/phpunit/src/TextUI/Application.php(437): PHPUnit\Runner\Extension\ExtensionBootstrapper->bootstrap('Clockwork\\Suppo...', Array)
#2 /var/www/vendor/phpunit/phpunit/src/TextUI/Application.php(139): PHPUnit\TextUI\Application->bootstrapExtensions(Object(PHPUnit\TextUI\Configuration\Configuration))
#3 /var/www/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run(Array)
#4 {main}

Expected Behavior

The tests should run without warning, Clockwork should be compatible with PHPUnit 11 and log the output.

Actual Behavior

Tests run through successfully with the above mentioned warning, making the extension incompatible with PHPUnit 11. No output found in clockwork

Environment

  • Clockwork Version: 5.3.4
  • PHPUnit Version: 11.5.12
  • PHP Version: 8.3.16
@itsgoingd
Copy link
Owner

Hey, thanks for the report, the new PHPUnit version might have introduced some breaking changes. I'll try to investigate this weekend.

@AndrewMast
Copy link

I'm getting the same thing

   WARN  Bootstrapping of extension Clockwork\Support\Laravel\Tests\ClockworkExtension failed: Interface "PHPUnit\Event\Test\AssertionSucceededSubscriber" not found
#0 /var/www/vendor/phpunit/phpunit/src/Runner/Extension/ExtensionBootstrapper.php(73): Clockwork\Support\Laravel\Tests\ClockworkExtension->bootstrap(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\Extension\Facade), Object(PHPUnit\Runner\Extension\ParameterCollection))
#1 /var/www/vendor/phpunit/phpunit/src/TextUI/Application.php(437): PHPUnit\Runner\Extension\ExtensionBootstrapper->bootstrap('Clockwork\\Suppo...', Array)
#2 /var/www/vendor/phpunit/phpunit/src/TextUI/Application.php(139): PHPUnit\TextUI\Application->bootstrapExtensions(Object(PHPUnit\TextUI\Configuration\Configuration))
#3 /var/www/vendor/pestphp/pest/src/Kernel.php(103): PHPUnit\TextUI\Application->run(Array)
#4 /var/www/vendor/pestphp/pest/bin/pest(184): Pest\Kernel->handle(Array, Array)
#5 /var/www/vendor/pestphp/pest/bin/pest(192): {closure}()
#6 /var/www/vendor/bin/pest(119): include('/var/www/vendor...')
#7 {main}

@nicolus
Copy link

nicolus commented Apr 4, 2025

Hey, thanks for the report, the new PHPUnit version might have introduced some breaking changes. I'll try to investigate this weekend.

Another issue I'm getting with Laravel 12 and PHPUnit 11, using the Clockwork\Support\Laravel\Tests\UsesClockwork Trait :
Fatal error: Cannot override final method PHPUnit\Framework\Assert::assertThat()

It looks like some methods have been made final in PHPUnit 11 and that might make things harder

@itsgoingd
Copy link
Owner

I've added PHPUnit 11+ and Pest 3 compatibility in master (8a37d3c), please give it a try and let me know how it works for you.

Unfortunately some changes made in PHPUnit 11 make the integration more tricky:

  • We can no longer log all executed asserts, since the events we used to do so were removed and I couldn't find any other way to do it.
  • For failed tests we now need to re-create the Laravel application by calling TestCase::createApplication, since the "passed" event is now called after tear-down, when the original application object is no longer available. This will lower performance and might cause issues in some rare cases.

With PHPUnit 10 and lower, asserts are still supported and no extra performance overhead is incurred.

@nicolus You shouldn't be using this trait, see here for PHPUnit 10+ installation instructions - https://underground.works/clockwork/#docs-collected-data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants