/** * @param callable $applicationBuilder * @param EventListener[] $listeners */ public function __construct(callable $applicationBuilder, array $listeners = []) { $this->store = new MemoryEventStore(); $this->application = $applicationBuilder($this->store); foreach ($listeners as $listener) { $this->application->addListener($listener); } $outcome = new Outcome(); $this->given = new Context($this->store, $listeners); $this->when = new Action($this->application, $outcome); $this->then = new Expectation($this->application, $this->store, $outcome); }
/** * @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()); }
public function __invoke($commandOrQuery) { $this->outcome->reset(); $this->outcome->returned = $this->application->handle($commandOrQuery); }