Skip to content

Commit

Permalink
orm3 support restore
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Feb 5, 2024
1 parent df8b8e3 commit 667230f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
20 changes: 16 additions & 4 deletions tests/Query/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DoctrineExtensions\Tests\Query;

use Composer\InstalledVersions;
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
Expand All @@ -20,13 +21,24 @@ class DbTestCase extends TestCase

public function setUp(): void
{
$this->configuration = new Configuration();
$this->configuration->setMetadataCache(new ArrayAdapter());
$this->configuration->setQueryCache(new ArrayAdapter());
if (method_exists(ORMSetup::class, 'createAttributeMetadataConfiguration')) {
$this->configuration = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/../Entities'], true);
} else {
$this->configuration = new Configuration();
$this->configuration->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities']));
}

if (method_exists($this->configuration, 'setMetadataCacheImpl') && method_exists($this->configuration, 'setQueryCacheImpl')) {
$this->configuration->setMetadataCacheImpl(new ArrayAdapter());
$this->configuration->setQueryCacheImpl(new ArrayAdapter());
} else {
$this->configuration->setMetadataCache(new ArrayAdapter());
$this->configuration->setQueryCache(new ArrayAdapter());
}

$this->configuration->setProxyDir(__DIR__ . '/Proxies');
$this->configuration->setProxyNamespace('DoctrineExtensions\Tests\Proxies');
$this->configuration->setAutoGenerateProxyClasses(true);
$this->configuration->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../Entities']));
$this->entityManager = new EntityManager(
DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $this->configuration),
$this->configuration
Expand Down
1 change: 1 addition & 0 deletions tests/Types/CarbonDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function setUp(): void
$config->setMetadataCache(new ArrayAdapter());
$config->setQueryCache(new ArrayAdapter());
}

$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('DoctrineExtensions\Tests\PHPUnit\Proxies');
$config->setAutoGenerateProxyClasses(true);
Expand Down
19 changes: 15 additions & 4 deletions tests/Types/ZendDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@ public static function setUpBeforeClass(): void

public function setUp(): void
{
$config = new Configuration();
$config->setMetadataCache(new ArrayAdapter());
$config->setQueryCache(new ArrayAdapter());
if (method_exists(ORMSetup::class, 'createAttributeMetadataConfiguration')) {
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/../Entities'], true);
} else {
$config = new Configuration();
$config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities']));
}

if (method_exists($config, 'setMetadataCacheImpl') && method_exists($config, 'setQueryCacheImpl')) {
$config->setMetadataCacheImpl(new ArrayAdapter());
$config->setQueryCacheImpl(new ArrayAdapter());
} else {
$config->setMetadataCache(new ArrayAdapter());
$config->setQueryCache(new ArrayAdapter());
}

$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('DoctrineExtensions\Tests\PHPUnit\Proxies');
$config->setAutoGenerateProxyClasses(true);
$config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities']));

$this->em = new EntityManager(
DriverManager::getConnection([
Expand Down

0 comments on commit 667230f

Please sign in to comment.