Registering your PHPUnit test as an event subscriber for testing events

Matt Glaman
3 min readJan 3, 2022

I love leveraging events in my application architecture. Drupal uses the EventDispatcher component from Symfony, which implements the Mediator and Observer design patterns. This allows for business logic to be extensible without making systems entirely coupled. The originating system dispatches an event and allows any other system to react to that event or modify data associated with that event. The originating system can then perform other interactions after its observers have processed the event.

--

--

Matt Glaman

PHP software engineer, open source contributor, and speaker