-
-
Save doctrinebot/dc80c18ef0726240bcad to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-115 - https://github.com/doctrine/doctrine2/issues/1750
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php | |
=================================================================== | |
--- tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php (revision 6662) | |
+++ tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php (working copy) | |
@@ -16,17 +16,10 @@ | |
{ | |
public function testGetMetadataForSingleClass() | |
{ | |
- $driverMock = new DriverMock(); | |
- $config = new \Doctrine\ORM\Configuration(); | |
- $config->setProxyDir(__DIR__ . '/../../Proxies'); | |
- $config->setProxyNamespace('Doctrine\Tests\Proxies'); | |
- $eventManager = new EventManager(); | |
- $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); | |
$mockDriver = new MetadataDriverMock(); | |
- $config->setMetadataDriverImpl($mockDriver); | |
+ $entityManager = $this->_createEntityManager($mockDriver); | |
- $entityManager = EntityManagerMock::create($conn, $config, $eventManager); | |
- | |
+ $conn = $entityManager->getConnection(); | |
$mockPlatform = $conn->getDatabasePlatform(); | |
$mockPlatform->setPrefersSequences(true); | |
$mockPlatform->setPrefersIdentityColumns(false); | |
@@ -65,6 +58,37 @@ | |
$this->assertTrue($cm1->hasField('name')); | |
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType); | |
} | |
+ | |
+ public function testGetMetadataGlobalNamespaceModel() | |
+ { | |
+ require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; | |
+ | |
+ $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache); | |
+ $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); | |
+ $metadataDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader); | |
+ $metadataDriver->setClassDirectory(__DIR__."/../../Models/Global/"); | |
+ | |
+ $entityManager = $this->_createEntityManager($metadataDriver); | |
+ | |
+ $m1 = $entityManager->getMetadataFactory()->getMetadataFor("DoctrineGlobal_Article"); | |
+ $m2 = $entityManager->getMetadataFactory()->getMetadataFor("\DoctrineGlobal_Article"); | |
+ | |
+ $this->assertSame($m1, $m2); | |
+ } | |
+ | |
+ protected function _createEntityManager($metadataDriver) | |
+ { | |
+ $driverMock = new DriverMock(); | |
+ $config = new \Doctrine\ORM\Configuration(); | |
+ $config->setProxyDir(__DIR__ . '/../../Proxies'); | |
+ $config->setProxyNamespace('Doctrine\Tests\Proxies'); | |
+ $eventManager = new EventManager(); | |
+ $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); | |
+ $mockDriver = new MetadataDriverMock(); | |
+ $config->setMetadataDriverImpl($metadataDriver); | |
+ | |
+ return EntityManagerMock::create($conn, $config, $eventManager); | |
+ } | |
} | |
/* Test subject class with overriden factory method for mocking purposes */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @entity | |
* @table(name="articles") | |
*/ | |
class DoctrineGlobal_Article | |
{ | |
/** | |
* @id | |
* @column(type="int") | |
*/ | |
protected $id; | |
/** | |
* @column(type="string") | |
*/ | |
protected $headline; | |
/** | |
* @column(type="text") | |
*/ | |
protected $text; | |
/** | |
* @ManyToMany(targetEntity="DoctrineGlobal_User") | |
* @JoinTable(name="author_articles", | |
* joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, | |
* inverseJoinColumns={@JoinColumn(name="author_id", referencedColumnName="id", unique=true)} | |
* ) | |
*/ | |
protected $author; | |
/** | |
* @ManyToMany(targetEntity="\DoctrineGlobal_User") | |
* @JoinTable(name="editor_articles", | |
* joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, | |
* inverseJoinColumns={@JoinColumn(name="editor_id", referencedColumnName="id", unique=true)} | |
* ) | |
*/ | |
protected $editor; | |
} | |
/** | |
* @Entity | |
* @Table(name="users") | |
*/ | |
class DoctrineGlobal_User | |
{ | |
/** | |
* @Id | |
* @column(type="integer") | |
* @var int | |
*/ | |
private $id; | |
/** | |
* @column(type="string", length=64) | |
* @var string | |
*/ | |
private $username; | |
/** | |
* @column(type="string", length=128) | |
* @var string | |
*/ | |
private $email; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment