public function testCanNotifyCleanupToListeners()
 {
     $unitOfWork = $this->unitOfWorkMock();
     // Todo: We should test that the listeners are triggered in the reversed order of registering.
     $this->listener1->expects($this->once())->method('onCleanup')->with($this->identicalTo($unitOfWork));
     $this->listener2->expects($this->once())->method('onCleanup')->with($this->identicalTo($unitOfWork));
     $this->listeners->onCleanup($unitOfWork);
 }
 private function commitTransaction()
 {
     if ($this->isTransactional()) {
         $this->listeners->onPrepareTransactionCommit($this);
         $this->transactionManager->commitTransaction();
     }
 }
 /**
  * @param UnitOfWorkListener $listener
  */
 public function registerListener(UnitOfWorkListener $listener)
 {
     $this->listeners->add($listener);
 }