Exemplo n.º 1
0
 /**
  * @param ServesEventStreamData $eventEnvelope
  * @param IdentifiesCommit $commit
  *
  * @return CommitEnvelope
  */
 public function putEventInEnvelopeForCommit(ServesEventStreamData $eventEnvelope, IdentifiesCommit $commit)
 {
     $streamIdentifier = $this->getStreamIdentifierForEventEnvelope($eventEnvelope);
     $payloadContract = $this->getPayloadContract();
     $payloadData = $this->serializeDataWithContract($eventEnvelope->getPayload(), $payloadContract);
     $metaDataContract = $this->getMetaDataContract();
     $metaData = $this->serializeDataWithContract($eventEnvelope->getMetaData(), $metaDataContract);
     $envelope = new CommitEnvelope();
     $envelope->setCommitId($commit->getCommitId());
     $envelope->setOccurredOn($eventEnvelope->getOccurredOn());
     $envelope->setCommittedOn($commit->getCommittedOn());
     $envelope->setStreamId($streamIdentifier->getStreamId());
     $envelope->setStreamIdContract($streamIdentifier->getStreamIdContract());
     $envelope->setPayloadContract($payloadContract->toString());
     $envelope->setPayload($payloadData);
     $envelope->setMetaDataContract($metaDataContract->toString());
     $envelope->setMetaData($metaData);
     $envelope->setFile($eventEnvelope->getFile());
     return $envelope;
 }
Exemplo n.º 2
0
 /**
  * @expectedException \hollodotme\MilestonES\Exceptions\RestoringFileWithContentFailed
  */
 public function testRestoringFilesOnReconstituionFailsWhenRestoreDirDoesNotExist()
 {
     $stream_identifier = new EventStreamIdentifier(new Identifier('Unit\\Test\\ID'));
     $envelope = new CommitEnvelope();
     $envelope->setStreamId($stream_identifier->getStreamId());
     $envelope->setStreamIdContract($stream_identifier->getStreamIdContract());
     $envelope->setFile(__DIR__ . '/../Fixures/eventFileTest');
     $persistence = new TestMemoryInvalidRestoreFileDir();
     $persistence->beginTransaction();
     $persistence->persistCommitEnvelope($envelope);
     $persistence->commitTransaction();
     $persistence->getEventStreamWithId($stream_identifier);
 }