X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FOrmTestCase.php;fp=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FOrmTestCase.php;h=4ad60d68bc9fe1f189a6b8ce3d321dfa24f17f5f;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fgalerie.git diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php new file mode 100644 index 0000000..4ad60d6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php @@ -0,0 +1,117 @@ +=')) { + $reader = new \Doctrine\Common\Annotations\CachedReader( + new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache() + ); + } + else if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { + // Register the ORM Annotations in the AnnotationRegistry + $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); + $reader->addNamespace('Doctrine\ORM\Mapping'); + $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); + } + else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) { + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $reader->setIgnoreNotImportedAnnotations(true); + $reader->setEnableParsePhpImports(false); + if ($alias) { + $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); + } else { + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + } + $reader = new \Doctrine\Common\Annotations\CachedReader( + new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() + ); + } else { + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + if ($alias) { + $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); + } else { + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + } + } + \Doctrine\Common\Annotations\AnnotationRegistry::registerFile( + __DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); + return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array)$paths); + } + + /** + * Creates an EntityManager for testing purposes. + * + * NOTE: The created EntityManager will have its dependant DBAL parts completely + * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then + * be configured in the tests to simulate the DBAL behavior that is desired + * for a particular test, + * + * @return Doctrine\ORM\EntityManager + */ + protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true) + { + $metadataCache = $withSharedMetadata + ? self::getSharedMetadataCacheImpl() + : new \Doctrine\Common\Cache\ArrayCache; + + $config = new \Doctrine\ORM\Configuration(); + + $config->setMetadataCacheImpl($metadataCache); + $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); + $config->setQueryCacheImpl(self::getSharedQueryCacheImpl()); + $config->setProxyDir(__DIR__ . '/Proxies'); + $config->setProxyNamespace('Doctrine\Tests\Proxies'); + + if ($conn === null) { + $conn = array( + 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock', + 'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock', + 'user' => 'john', + 'password' => 'wayne' + ); + } + + if (is_array($conn)) { + $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager); + } + + return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager); + } + + private static function getSharedMetadataCacheImpl() + { + if (self::$_metadataCacheImpl === null) { + self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + } + + return self::$_metadataCacheImpl; + } + + private static function getSharedQueryCacheImpl() + { + if (self::$_queryCacheImpl === null) { + self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + } + + return self::$_queryCacheImpl; + } +}