コード例 #1
0
 public function testCachesDistinctRepositoriesPerDistinctEntityManager()
 {
     $em1 = $this->createEntityManager();
     $em2 = $this->createEntityManager();
     $em1->expects($this->any())->method('getClassMetadata')->will($this->returnCallback(array($this, 'buildClassMetadata')));
     $em2->expects($this->any())->method('getClassMetadata')->will($this->returnCallback(array($this, 'buildClassMetadata')));
     $repo1 = $this->repositoryFactory->getRepository($em1, __CLASS__);
     $repo2 = $this->repositoryFactory->getRepository($em2, __CLASS__);
     $this->assertSame($repo1, $this->repositoryFactory->getRepository($em1, __CLASS__));
     $this->assertSame($repo2, $this->repositoryFactory->getRepository($em2, __CLASS__));
     $this->assertNotSame($repo1, $repo2);
 }
コード例 #2
0
 /**
  * FIXME: Re-creates object for every test. DI container ?
  * @param string $entityName
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 public function getRepository($entityName)
 {
     $em = $this->getEntityManager();
     $factory = new DefaultRepositoryFactory($em, $entityName);
     return $factory->getRepository($em, $entityName);
 }