public function testCanNotifyRollbackToListeners()
 {
     $unitOfWork = $this->unitOfWorkMock();
     $failureCause = new \Exception();
     // Todo: We should test that the listeners are triggered in the reversed order of registering.
     $this->listener1->expects($this->once())->method('onRollback')->with($this->identicalTo($unitOfWork), $this->identicalTo($failureCause));
     $this->listener2->expects($this->once())->method('onRollback')->with($this->identicalTo($unitOfWork), $this->identicalTo($failureCause));
     $this->listeners->onRollback($unitOfWork, $failureCause);
 }
 /**
  * @param \Exception $failureCause
  */
 public function rollback(\Exception $failureCause)
 {
     $this->registeredAggregates->clear();
     $this->stagingEvents->clear();
     try {
         if ($this->isTransactional()) {
             $this->transactionManager->rollbackTransaction();
         }
     } finally {
         $this->listeners->onRollback($this, $failureCause);
     }
 }