diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 1376a3aa2..35e4aa9a8 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -130,6 +130,20 @@ class Configuration extends \Doctrine\DBAL\Configuration $this->_attributes['metadataDriverImpl'] = $driverImpl; } + /** + * Add a new default annotation driver with a correctly configured annotation reader. + * + * @param array $paths + * @return Mapping\Driver\AnnotationDriver + */ + public function newDefaultAnnotationDriver($paths = array()) + { + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + + return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array)$paths); + } + /** * Adds a namespace under a certain alias. * diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index b4ca023aa..6466b15dc 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -235,8 +235,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $driverImpl = \Doctrine\ORM\Mapping\Driver\AnnotationDriver::create(); - $config->setMetadataDriverImpl($driverImpl); + $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); $conn = $this->sharedFixture['conn']; $conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 1167ad0b8..3991d5b6d 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -30,9 +30,8 @@ abstract class OrmTestCase extends DoctrineTestCase } else { $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); } - - $driverImpl = \Doctrine\ORM\Mapping\Driver\AnnotationDriver::create(); - $config->setMetadataDriverImpl($driverImpl); + + $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); $config->setQueryCacheImpl(self::getSharedQueryCacheImpl()); $config->setProxyDir(__DIR__ . '/Proxies');