Skip to content

Commit

Permalink
Merge pull request #1522 from scyzoryck/stop-using-em-create
Browse files Browse the repository at this point in the history
refactor(test): Stop using EntityManager::create() method. Use constructor instead.
  • Loading branch information
scyzoryck authored Oct 29, 2023
2 parents 8c4640e + b01d21f commit f240275
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions tests/Metadata/Driver/DoctrineDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace JMS\Serializer\Tests\Metadata\Driver;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver as DoctrineAnnotationDriver;
use Doctrine\ORM\Mapping\Driver\AttributeDriver as DoctrineAttributeDriver;
use Doctrine\ORM\Version as ORMVersion;
use Doctrine\Persistence\ManagerRegistry;
use JMS\Serializer\Metadata\Driver\AnnotationDriver;
use JMS\Serializer\Metadata\Driver\AnnotationOrAttributeDriver;
Expand All @@ -31,10 +31,6 @@ public function getMetadata()

public function testMetadataForEmbedded()
{
if (ORMVersion::compare('2.5') >= 0) {
$this->markTestSkipped('Not using Doctrine ORM >= 2.5 with Embedded entities');
}

$refClass = new \ReflectionClass(BlogPostWithEmbedded::class);
$meta = $this->getDoctrineDriver()->loadMetadataForClass($refClass);
self::assertNotNull($meta);
Expand Down Expand Up @@ -149,12 +145,12 @@ protected function getEntityManager()
);
}

$conn = [
$conn = DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'memory' => true,
];
]);

return EntityManager::create($conn, $config);
return new EntityManager($conn, $config);
}

public function getMetadataDriver()
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/Doctrine/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private function createEntityManager(Connection $con)
$cfg->setProxyNamespace('JMS\Serializer\DoctrineProxy');
$cfg->setProxyDir(sys_get_temp_dir() . '/serializer-test-proxies');

return EntityManager::create($con, $cfg);
return new EntityManager($con, $cfg);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/Doctrine/ObjectConstructorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ private function createEntityManager(Connection $con, ?Configuration $cfg = null
$cfg->setProxyNamespace('JMS\Serializer\DoctrineProxy');
$cfg->setProxyDir(sys_get_temp_dir() . '/serializer-test-proxies');

return EntityManager::create($con, $cfg);
return new EntityManager($con, $cfg);
}

/**
Expand Down

0 comments on commit f240275

Please sign in to comment.