function commandByDefault() { $this->application(GenericAggregateFactory::genericRoot(function ($command) { $this->assert->equals($command, 'foo'); }))->handle('foo'); }
/** * @param EventStore $store * @param AggregateFactory|null $aggregates * @param ProjectionFactory|null $projections */ public function __construct(EventStore $store, AggregateFactory $aggregates = null, ProjectionFactory $projections = null) { parent::__construct($store, $aggregates ?: GenericAggregateFactory::genericRoot(), $projections ?: GenericProjectionFactory::genericProjection()); }
private function genericHandler($aggregateRoot) { return $this->handler(GenericAggregateFactory::staticRoot($aggregateRoot)); }
function invokeListeners() { $heard = []; $listenToAll = new CallbackListener(function ($event) use(&$heard) { $heard[] = $event; }); $listensToAllButBar = new CallbackListener(function ($event) use(&$heard) { $heard[] = $event . ' again'; }, function ($event) { return $event != 'bard'; }); $aggregate = Aggregate::genericRoot(function ($command) { return $command . 'd'; }); $spec = $this->command($aggregate, [$listenToAll, $listensToAllButBar]); $spec->given('food'); $spec->given('bard'); $spec->when('baz'); $this->assert->equals($heard, ['food', 'food again', 'bard', 'bazd', 'bazd again']); }