public function testResolveTargetDocumentListenerCanResolveTargetDocument()
 {
     $evm = $this->dm->getEventManager();
     $this->listener->addResolveTargetDocument('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\ResolveTargetInterface', 'Doctrine\\ODM\\MongoDB\\Tests\\Tools\\ResolveTargetDocument', array());
     $this->listener->addResolveTargetDocument('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\TargetInterface', 'Doctrine\\ODM\\MongoDB\\Tests\\Tools\\TargetDocument', array());
     $evm->addEventListener(Events::loadClassMetadata, $this->listener);
     $cm = $this->dm->getClassMetadata('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\ResolveTargetDocument');
     $meta = $cm->associationMappings;
     $this->assertSame('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\ResolveTargetDocument', $meta['refOne']['targetDocument']);
     $this->assertSame('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\TargetDocument', $meta['refMany']['targetDocument']);
     $this->assertSame('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\ResolveTargetDocument', $meta['embedOne']['targetDocument']);
     $this->assertSame('Doctrine\\ODM\\MongoDB\\Tests\\Tools\\TargetDocument', $meta['embedMany']['targetDocument']);
 }
 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     $map = [];
     $metadata = $event->getClassMetadata();
     foreach ($metadata->discriminatorMap as $discriminatorName => $discriminatorClass) {
         if (isset($this->resolveTargetEntities[$discriminatorClass])) {
             $map[$discriminatorName] = $this->resolveTargetEntities[$discriminatorClass]['targetDocument'];
         }
     }
     $metadata->setDiscriminatorMap($map);
     parent::loadClassMetadata($event);
 }