From b01d21fbb016f9435380ef54bc751c9842f7e7f8 Mon Sep 17 00:00:00 2001 From: Marcin Czarnecki Date: Fri, 27 Oct 2023 15:37:41 +0200 Subject: [PATCH] refactor(test): Stop using EntityManager::create() method. Use constructor instead --- tests/Metadata/Driver/DoctrineDriverTest.php | 12 ++++-------- tests/Serializer/Doctrine/IntegrationTest.php | 2 +- tests/Serializer/Doctrine/ObjectConstructorTest.php | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/Metadata/Driver/DoctrineDriverTest.php b/tests/Metadata/Driver/DoctrineDriverTest.php index 4fe357754..1dc3565a4 100644 --- a/tests/Metadata/Driver/DoctrineDriverTest.php +++ b/tests/Metadata/Driver/DoctrineDriverTest.php @@ -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; @@ -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); @@ -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() diff --git a/tests/Serializer/Doctrine/IntegrationTest.php b/tests/Serializer/Doctrine/IntegrationTest.php index eb9111872..4ce720acf 100644 --- a/tests/Serializer/Doctrine/IntegrationTest.php +++ b/tests/Serializer/Doctrine/IntegrationTest.php @@ -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); } } diff --git a/tests/Serializer/Doctrine/ObjectConstructorTest.php b/tests/Serializer/Doctrine/ObjectConstructorTest.php index 67ddef9f2..f519f561f 100644 --- a/tests/Serializer/Doctrine/ObjectConstructorTest.php +++ b/tests/Serializer/Doctrine/ObjectConstructorTest.php @@ -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); } /**