/** * @test * @depends it_should_commit_and_fetch_events * @dataProvider providePersistence * @param Persistence $persistence */ public function it_should_throw_when_events_have_been_committed_elsewhere(Persistence $persistence) { $commitId = CommitId::generate(); $streamContract = Contract::with('My.Contract'); $streamId = OrderId::generate(); $eventEnvelope = EventEnvelope::wrap(EventId::generate(), Contract::with("My.SomethingHasHappened"), "My payload2"); $this->setExpectedException(OptimisticConcurrencyFailed::class); $persistence->commit($commitId, $streamContract, $streamId, $expectedStreamVersion = 1, [$eventEnvelope]); }
public function commit(CommitId $commitId) { $this->persistence->commit($commitId, $this->streamContract, $this->streamId, count($this->committedEventEnvelopes), $this->pendingEventEnvelopes); $this->committedEventEnvelopes = array_merge($this->committedEventEnvelopes, $this->pendingEventEnvelopes); $this->pendingEventEnvelopes = []; }