Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.36 KB

adding-and-removing-projectors-and-reactors.md

File metadata and controls

61 lines (43 loc) · 1.36 KB
title weight
Adding and Removing Projectors and Reactors
10

You can add and remove projectors and reactors via the Projectionist facade.

Whilst this package can auto-discover your event handlers, it is still useful to be able to add and remove projectors or reactors for your test suite. For example, a slow reactor might be worth removing to speed up your tests if the behaviour of that reactor is not relevant for the feature you are testing.

Adding Projectors

Adding one projector:

Projectionist::addProjector(TransactionCountProjector::class);

Adding multiple projectors:

Projectionist::addProjectors([
    AccountBalanceProjector::class,
    TransactionCountProjector::class,
]);

Adding Reactors

Adding one reactor:

Projectionist::addReactor(SendMailReactor::class);

Adding multiple reactors:

Projectionist::addReactors([
    SendMailReactor::class,
    SendPushNotificationReactor::class,
]);

Removing Projectors and Reactors

A projector and a reactor are both event handlers. You can remove either of them with the same function.

Removing one event handler:

Projectionist::withoutEventHandler(SendPushNotificationReactor::class);

Removing multiple event handlers:

Projectionist::withoutEventHandlers([
    TransactionCountProjector::class,
    SendPushNotificationReactor::class,
]);