public function it_can_be_created(ProxyEventContainerFactoryStub $eventContainerFactory, EventContainer $eventContainer, ProxyEventStreamFactoryStub $eventStreamFactory, EventStream $eventStream) { $this->beConstructedThrough('create', [new UuidAggregateRootIdentifier(), $eventContainerFactory, $eventStreamFactory]); $eventContainerFactory->proxy(Argument::any())->willReturn(); $eventContainerFactory->create(Argument::any())->willReturn($eventContainer); $eventStreamFactory->proxy(Argument::any())->willReturn(); $eventStreamFactory->create(Argument::any())->willReturn($eventStream); // The container should be initialized. $eventContainer->initializeSequenceNumber(0)->shouldBeCalledTimes(1); // The event added. $eventContainer->addEventFromPayload(Argument::any())->shouldBeCalledTimes(1); // The last committed should be 0 at tis stage, cause nothing has been committed yet. $eventContainer->lastCommittedSequenceNumber()->willReturn(0); $this->lastCommittedEventSequenceNumber()->shouldReturn(0); // We commit the changes. $eventContainer->lastSequenceNumber()->willReturn(1); // We ensure the container is cleared. $eventContainer->commit()->shouldBeCalled(); $this->commitChanges(); // Todo: test }
public function setEventStreamFactoryProxy(ProxyEventStreamFactoryStub $proxy) { $proxy->proxy(parent::eventStreamFactory()); $this->eventStreamFactory = $proxy; }