/** * @expectedException \RayRutjes\DomainFoundation\Repository\ConcurrencyException */ public function testShouldRaiseAConcurrencyExceptionIfConcurrencyConflictIsDetected() { $aggregateRootType = Contract::createFromClassName('stdClass'); $eventStream = $this->provideStubbedEventStream(); $pdoException = new \PDOException(); $pdoException->errorInfo[0] = '23000'; $this->statement->method('execute')->will($this->throwException($pdoException)); $this->eventStore->append($aggregateRootType, $eventStream); }
/** * @expectedException \RayRutjes\DomainFoundation\Repository\ConcurrencyException */ public function testDetectsConcurrencyAndThrowsTheAccordingException() { $aggregateRootIdentifier = new AggregateRootIdentifierStub(Uuid::NIL); $aggregateRootType = Contract::createFromClassName('Product'); $messageIdentifier = new MessageIdentifier(UUID::NIL); $payload = new PayloadStub(); $event = new GenericEvent($aggregateRootIdentifier, 1, $messageIdentifier, $payload); $eventStream = new GenericEventStream([$event]); $this->eventStore->append($aggregateRootType, $eventStream); }