コード例 #1
0
 public function testCanPublishEachEventThroughTheEventBusItWasRegisteredWith()
 {
     $event1 = $this->event();
     $event2 = $this->event();
     $event3 = $this->event();
     $eventBus1 = $this->eventBusMock();
     $eventBus1->expects($this->once())->method('publish')->with($this->identicalTo($event1));
     $eventBus2 = $this->eventBusMock();
     $eventBus2->expects($this->once())->method('publish')->with($this->identicalTo($event2), $this->identicalTo($event3));
     $this->container->add($event1, $eventBus1);
     $this->container->add($event2, $eventBus2);
     $this->container->add($event3, $eventBus2);
     $this->container->publishEvents();
     return $this->container;
 }
コード例 #2
0
 public function commit()
 {
     $this->assertHasStarted();
     try {
         $this->listeners->onPrepareCommit($this, $this->registeredAggregates->all(), $this->stagingEvents->all());
         $this->registeredAggregates->saveAggregateRoots();
         $this->stagingEvents->publishEvents();
         $this->commitTransaction();
         $this->listeners->afterCommit($this);
     } catch (\RuntimeException $exception) {
         $this->rollback($exception);
         throw $exception;
     } finally {
         $this->stop();
         $this->listeners->onCleanup($this);
     }
 }