/**
  * Applies changes from a ForumEvent changeset to the entity manager
  * @param    Courtyard\Forum\Event\ForumEvent
  */
 protected function applyEventChangeset(ForumEvent $event)
 {
     foreach ($event->getEntitiesToPersist() as $persistEntity) {
         $this->em->persist($persistEntity);
     }
     foreach ($event->getEntitiesToRemove() as $removeEntity) {
         $this->em->remove($removeEntity);
     }
 }
 public function testEntitiesAreRemovedWhenMarked()
 {
     $topic = $this->getMock('Courtyard\\Forum\\Entity\\Topic');
     $post = $this->getMock('Courtyard\\Forum\\Entity\\Post');
     $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $event = new ForumEvent();
     $event->addEntityToRemove($topic);
     $event->addEntityToRemove($post);
     $transaction = new TransactionEvents();
     $transaction->addFirstPass('event', $event);
     $entityManager = $this->getEntityManager();
     $entityManager->expects($this->at(1))->method('remove')->with($topic);
     $entityManager->expects($this->at(2))->method('remove')->with($post);
     $dispatcher = new TransactionDispatcher($entityManager, $eventDispatcher);
     $dispatcher->dispatch($transaction);
 }