*/ class ProxyFactoryTest extends \Doctrine\Tests\OrmTestCase { /** * @var ConnectionMock */ private $connectionMock; /** * @var UnitOfWorkMock */ private $uowMock; /** * @var EntityManagerMock */ private $emMock; /** * @var \Doctrine\ORM\Proxy\ProxyFactory */ private $proxyFactory; /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); $this->connectionMock = new ConnectionMock(array(), new DriverMock()); $this->emMock = EntityManagerMock::create($this->connectionMock); $this->uowMock = new UnitOfWorkMock($this->emMock); $this->emMock->setUnitOfWork($this->uowMock); $this->proxyFactory = new ProxyFactory($this->emMock, sys_get_temp_dir(), 'Proxies', true); } public function testReferenceProxyDelegatesLoadingToThePersister() { $identifier = array('id' => 42); $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; $persister = $this->getMock('Doctrine\ORM\Persisters\BasicEntityPersister', array('load'), array(), '', false); $this->uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); $proxy = $this->proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier); $persister ->expects($this->atLeastOnce()) ->method('load') ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) ->will($this->returnValue(new \stdClass())); $proxy->getDescription(); } /** * @group DDC-1771 */ public function testSkipAbstractClassesOnGeneration() { $cm = new ClassMetadata(__NAMESPACE__ . '\\AbstractClass'); $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $this->assertNotNull($cm->reflClass); $num = $this->proxyFactory->generateProxyClasses(array($cm)); $this->assertEquals(0, $num, "No proxies generated."); } } abstract class AbstractClass { }