DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
512 stars 54 forks source link

[Bug] Wildcard listeners appending to events with every PHPUnit test started #653

Closed Jacobs63 closed 6 months ago

Jacobs63 commented 6 months ago

Environment:

Describe the bug:

Whenever a new PHPUnit test is started, the LdapServiceProvider adds logging via a wildcard event listener to \LdapRecord\Events\Dispatcher. Since these listeners are not flushed, this accumulates to over a thousand listeners when running my entire test suite, dramatically slowing the testing process.

I did not notice this being pointed anywhere in the Testing section of the application.

The current workaround I found to be working is to call Container::getInstance()->getConnectionManager()->flush() during the tearDown process on every test case.

Is that the correct approach, or should I call something else? Running DirectoryEmulator::tearDown has no effect here.

stevebauman commented 6 months ago

Oh good catch @Jacobs63! Let me check this out. Appreciate the detailed bug report 🙏

stevebauman commented 6 months ago

Ok I've just released v3.6.4 with a patch for this.

You should definitely only have to execute DirectoryEmulator::tearDown() to tear down the whole LdapRecord test suite 👍

Run composer update and you're all set! Thanks again @Jacobs63 🙏

Jacobs63 commented 6 months ago

Hello,

confirming the latest release fixes this issue, thank you for the quick fix!

stevebauman commented 6 months ago

Awesome! Thanks for letting me know @Jacobs63 🙏