diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 19d319dbe..9bc3ca054 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -521,6 +521,12 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface $this->initialize(); } + // Check for namespace alias + if (strpos($class, ':') !== false) { + list($namespaceAlias, $simpleClassName) = explode(':', $class); + $class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + } + return $this->driver->isTransient($class); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index dbb82f054..00b8f5f16 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Common\EventManager; +use Doctrine\ORM\Mapping\ClassMetadataFactory; require_once __DIR__ . '/../../TestInit.php'; @@ -81,6 +82,51 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase $this->assertFalse($h2); $this->assertTrue($h1); } + + /** + * @group DDC-1512 + */ + public function testIsTransient() + { + $cmf = new ClassMetadataFactory(); + $driver = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver->expects($this->at(0)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) + ->will($this->returnValue(true)); + $driver->expects($this->at(1)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) + ->will($this->returnValue(false)); + + $em = $this->_createEntityManager($driver); + + $this->assertTrue($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsUser')); + $this->assertFalse($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsArticle')); + } + + /** + * @group DDC-1512 + */ + public function testIsTransientEntityNamespace() + { + $cmf = new ClassMetadataFactory(); + $driver = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver->expects($this->at(0)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) + ->will($this->returnValue(true)); + $driver->expects($this->at(1)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) + ->will($this->returnValue(false)); + + $em = $this->_createEntityManager($driver); + $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); + + $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); + $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); + } protected function _createEntityManager($metadataDriver) {