diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php new file mode 100644 index 000000000..0beac425d --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -0,0 +1,87 @@ +entityManager = $this->getMock('Doctrine\\ORM\\EntityManagerInterface'); + $this->configuration = $this->getMock('Doctrine\\ORM\\Configuration'); + $this->repositoryFactory = new DefaultRepositoryFactory(); + + $this + ->entityManager + ->expects($this->any()) + ->method('getClassMetadata') + ->will($this->returnCallback(array($this, 'buildClassMetadata'))); + + $this + ->entityManager + ->expects($this->any()) + ->method('getConfiguration') + ->will($this->returnValue($this->configuration)); + + $this + ->configuration + ->expects($this->any()) + ->method('getDefaultRepositoryClassName') + ->will($this->returnValue('Doctrine\\Tests\\Models\\DDC869\\DDC869PaymentRepository')); + } + + public function testCreatesRepositoryFromDefaultRepositoryClass() + { + $this->assertInstanceOf( + 'Doctrine\\Tests\\Models\\DDC869\\DDC869PaymentRepository', + $this->repositoryFactory->getRepository($this->entityManager, __CLASS__) + ); + } + + /** + * @private + * + * @param string $className + * + * @return \PHPUnit_Framework_MockObject_MockObject|\Doctrine\Common\Persistence\Mapping\ClassMetadata + */ + public function buildClassMetadata($className) + { + $metadata = $this + ->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata') + ->disableOriginalConstructor() + ->getMock(); + + $metadata->expects($this->any())->method('getName')->will($this->returnValue($className)); + + $metadata->customRepositoryClassName = null; + + return $metadata; + } +} \ No newline at end of file