Skip to content

Commit

Permalink
Merge pull request #6549 from Majkl578/dev/OrmTestCase-fix-annotation…
Browse files Browse the repository at this point in the history
…-reader

[develop] OrmTestCase: Always use full AnnotationReader, drop legacy versions
  • Loading branch information
Ocramius authored Jul 12, 2017
2 parents 3a2848b + 39e2008 commit 884feea
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions tests/Doctrine/Tests/OrmTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Doctrine\Common\Annotations;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Version;
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\Cache\CacheConfiguration;
use Doctrine\ORM\Cache\DefaultCacheFactory;
Expand Down Expand Up @@ -58,43 +57,12 @@ abstract class OrmTestCase extends DoctrineTestCase

/**
* @param array $paths
* @param mixed $alias
*
* @return \Doctrine\ORM\Mapping\Driver\AnnotationDriver
*/
protected function createAnnotationDriver($paths = [], $alias = null)
protected function createAnnotationDriver($paths = [])
{
if (version_compare(Version::VERSION, '3.0.0-DEV', '>=')) {
$reader = new Annotations\CachedReader(new Annotations\AnnotationReader(), new ArrayCache());
} else if (version_compare(Version::VERSION, '2.2.0-DEV', '>=')) {
// Register the ORM Annotations in the AnnotationRegistry
$reader = new Annotations\SimpleAnnotationReader();

$reader->addNamespace('Doctrine\ORM\Annotation');

$reader = new Annotations\CachedReader($reader, new ArrayCache());
} else if (version_compare(Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
$reader = new Annotations\AnnotationReader();

$reader->setIgnoreNotImportedAnnotations(true);
$reader->setEnableParsePhpImports(false);

if ($alias) {
$reader->setAnnotationNamespaceAlias('Doctrine\ORM\Annotation\\', $alias);
} else {
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Annotation\\');
}

$reader = new Annotations\CachedReader(new Annotations\IndexedReader($reader), new ArrayCache());
} else {
$reader = new Annotations\AnnotationReader();

if ($alias) {
$reader->setAnnotationNamespaceAlias('Doctrine\ORM\Annotation\\', $alias);
} else {
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Annotation\\');
}
}
$reader = new Annotations\CachedReader(new Annotations\AnnotationReader(), new ArrayCache());

Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../../../lib/Doctrine/ORM/Annotation/DoctrineAnnotations.php");

Expand Down

0 comments on commit 884feea

Please sign in to comment.