diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 8e76b29ee..13cc4aae6 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -135,9 +135,16 @@ class ProxyFactory '', '', '' ); + + if(substr($class->name, 0, 1) == "\\") { + $className = substr($class->name, 1); + } else { + $className = $class->name; + } + $replacements = array( $this->_proxyNamespace, - $proxyClassName, $class->name, + $proxyClassName, $className, $methods, $sleepImpl, $constructorInv ); diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php index cad4dce53..bef18a0c3 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php @@ -23,6 +23,10 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase private $_connectionMock; private $_uowMock; private $_emMock; + + /** + * @var \Doctrine\ORM\Proxy\ProxyFactory + */ private $_proxyFactory; protected function setUp() @@ -103,10 +107,22 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase $this->assertNotEquals($referenceProxyClass, $associationProxyClass); } - protected function _getAssociationMock() + public function testNonNamespacedProxyGeneration() { - $assoc = $this->getMock('Doctrine\ORM\Mapping\AssociationMapping', array('load'), array(), '', false, false, false); - return $assoc; + require_once dirname(__FILE__)."/fixtures/NonNamespacedProxies.php"; + + $className = "\DoctrineOrmTestEntity"; + $proxyName = "DoctrineOrmTestEntityProxy"; + $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); + $classMetadata->setIdentifier(array('id')); + + $this->_proxyFactory->generateProxyClasses(array($classMetadata)); + + $classCode = file_get_contents(dirname(__FILE__)."/generated/".$proxyName.".php"); + + $this->assertNotContains("class DoctrineOrmTestEntityProxy extends \\\\DoctrineOrmTestEntity", $classCode); + $this->assertContains("class DoctrineOrmTestEntityProxy extends \\DoctrineOrmTestEntity", $classCode); } protected function _getMockPersister() diff --git a/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php b/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php new file mode 100644 index 000000000..88c06e449 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php @@ -0,0 +1,13 @@ +