From 0ef08c5dfb3bd2021cc7155a36c39758cfd4466e Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 28 Jun 2022 23:44:23 +0200 Subject: [PATCH 01/13] preUpdate: Add restriction that changed field needs to be in computed changeset (#9871) --- docs/en/reference/events.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index a42cb807f6..7c391696b2 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -644,6 +644,9 @@ A simple example for this event looks like: if ($eventArgs->getEntity() instanceof User) { if ($eventArgs->hasChangedField('name') && $eventArgs->getNewValue('name') == 'Alice') { $eventArgs->setNewValue('name', 'Bob'); + // The following will only work if `status` is already present in the computed changeset. + // Otherwise it will throw an InvalidArgumentException: + $eventArgs->setNewValue('status', 'active'); } } } From b1419ddc6cbfa37ba1c84d9ecf0545b8661644ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 1 Jul 2022 20:01:32 +0200 Subject: [PATCH 02/13] Migrate more usages of SchemaTool::createSchema() When I introduced OrmFunctionalTestCase::createSchemaForModels(), I made several wrong assumptions: - the call is always wrapped in a try / catch; - that try / catch is always typed with "Exception". Because of that, I missed, many, many occurrences of SchemaTool::createSchema(). I recently noticed that contributors kept using the SchemaTool::createSchema() and figured not everything had been migrated. Migrating some of them did not result in something far better until I also introduced similar methods for SchemaTool::getUpdateSchemaSql() and SchemaTool::getSchemaFromMetadata(). --- .../Functional/InsertableUpdatableTest.php | 11 +---- .../Functional/MergeCompositeToOneKeyTest.php | 8 ++-- .../Functional/MergeSharedEntitiesTest.php | 11 +---- .../Tests/ORM/Functional/NotifyPolicyTest.php | 5 +-- ...eToOneInverseSideLoadAfterDqlQueryTest.php | 10 +---- ...OneToOneSelfReferentialAssociationTest.php | 4 +- .../OneToOneSingleTableInheritanceTest.php | 10 ++--- ...edJoinedTableInheritanceCollectionTest.php | 10 ++--- .../ORM/Functional/SchemaTool/DBAL483Test.php | 19 ++------ .../ORM/Functional/SchemaTool/DDC214Test.php | 44 +++++-------------- .../SchemaTool/PostgreSqlSchemaToolTest.php | 14 ++---- .../SequenceEmulatedIdentityStrategyTest.php | 4 +- .../ORM/Functional/Ticket/DDC1080Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC1163Test.php | 12 +++-- .../ORM/Functional/Ticket/DDC1181Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC1193Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC1225Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC1250Test.php | 4 +- .../ORM/Functional/Ticket/DDC1300Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC1383Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC1392Test.php | 11 +---- .../ORM/Functional/Ticket/DDC1400Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC1404Test.php | 17 +++---- .../ORM/Functional/Ticket/DDC1436Test.php | 10 +---- .../ORM/Functional/Ticket/DDC144Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC1452Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC1454Test.php | 11 +---- .../ORM/Functional/Ticket/DDC1458Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC1509Test.php | 16 +++---- .../ORM/Functional/Ticket/DDC1514Test.php | 16 +++---- .../ORM/Functional/Ticket/DDC1515Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC1526Test.php | 6 +-- .../ORM/Functional/Ticket/DDC1548Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC1595Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC1690Test.php | 5 +-- .../ORM/Functional/Ticket/DDC1707Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC1787Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC1925Test.php | 7 +-- .../ORM/Functional/Ticket/DDC192Test.php | 15 +++---- .../ORM/Functional/Ticket/DDC1998Test.php | 6 +-- .../ORM/Functional/Ticket/DDC199Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC2012Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC2084Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC2106Test.php | 6 +-- .../ORM/Functional/Ticket/DDC211Test.php | 7 +-- .../ORM/Functional/Ticket/DDC2138Test.php | 21 ++++----- .../ORM/Functional/Ticket/DDC2175Test.php | 6 +-- .../ORM/Functional/Ticket/DDC2214Test.php | 7 +-- .../ORM/Functional/Ticket/DDC2230Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC2231Test.php | 6 +-- .../ORM/Functional/Ticket/DDC2252Test.php | 12 +++-- .../ORM/Functional/Ticket/DDC2256Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC2306Test.php | 12 +++-- .../ORM/Functional/Ticket/DDC2346Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC2350Test.php | 7 +-- .../ORM/Functional/Ticket/DDC237Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC2415Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC2494Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC2575Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC2579Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC258Test.php | 12 +++-- .../ORM/Functional/Ticket/DDC2692Test.php | 11 +---- .../ORM/Functional/Ticket/DDC2759Test.php | 19 +++----- .../ORM/Functional/Ticket/DDC2780Test.php | 7 +-- .../ORM/Functional/Ticket/DDC279Test.php | 12 +++-- .../ORM/Functional/Ticket/DDC2825Test.php | 7 +-- .../ORM/Functional/Ticket/DDC2862Test.php | 11 +---- .../ORM/Functional/Ticket/DDC2931Test.php | 11 +---- .../ORM/Functional/Ticket/DDC2984Test.php | 11 +---- .../ORM/Functional/Ticket/DDC2996Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC3033Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC3042Test.php | 7 +-- .../ORM/Functional/Ticket/DDC3170Test.php | 12 +++-- .../ORM/Functional/Ticket/DDC3192Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC3300Test.php | 6 +-- .../ORM/Functional/Ticket/DDC3303Test.php | 2 +- .../ORM/Functional/Ticket/DDC345Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC353Test.php | 11 +---- .../ORM/Functional/Ticket/DDC3582Test.php | 2 +- .../ORM/Functional/Ticket/DDC3597Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC3634Test.php | 15 +++---- .../ORM/Functional/Ticket/DDC371Test.php | 7 +-- .../ORM/Functional/Ticket/DDC422Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC425Test.php | 6 +-- .../ORM/Functional/Ticket/DDC440Test.php | 5 +-- .../ORM/Functional/Ticket/DDC444Test.php | 6 +-- .../ORM/Functional/Ticket/DDC448Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC493Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC512Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC513Test.php | 10 ++--- .../ORM/Functional/Ticket/DDC531Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC588Test.php | 6 +-- .../ORM/Functional/Ticket/DDC599Test.php | 14 ++---- .../ORM/Functional/Ticket/DDC6303Test.php | 14 +++--- .../ORM/Functional/Ticket/DDC719Test.php | 6 +-- .../ORM/Functional/Ticket/DDC809Test.php | 8 ++-- .../ORM/Functional/Ticket/DDC837Test.php | 14 +++--- .../ORM/Functional/Ticket/GH2947Test.php | 2 +- .../ORM/Functional/Ticket/GH5562Test.php | 10 ++--- .../ORM/Functional/Ticket/GH5762Test.php | 10 ++--- .../ORM/Functional/Ticket/GH5804Test.php | 4 +- .../ORM/Functional/Ticket/GH5887Test.php | 7 +-- .../ORM/Functional/Ticket/GH6141Test.php | 10 ++--- .../ORM/Functional/Ticket/GH6217Test.php | 10 ++--- .../ORM/Functional/Ticket/GH6362Test.php | 12 +++-- .../ORM/Functional/Ticket/GH6394Test.php | 7 +-- .../ORM/Functional/Ticket/GH6464Test.php | 10 ++--- .../ORM/Functional/Ticket/GH7735Test.php | 10 ++--- .../ORM/Functional/Ticket/GH7875Test.php | 19 ++++---- .../ORM/Functional/Ticket/Ticket2481Test.php | 4 +- .../Ticket4646InstanceOfAbstractTest.php | 8 ++-- .../Ticket4646InstanceOfMultiLevelTest.php | 10 ++--- .../Ticket4646InstanceOfParametricTest.php | 8 ++-- .../Ticket/Ticket4646InstanceOfTest.php | 8 ++-- ...46InstanceOfWithMultipleParametersTest.php | 12 ++--- .../ORM/Functional/UUIDGeneratorTest.php | 4 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 6 +-- .../ORM/Functional/VersionedOneToOneTest.php | 14 ++---- .../Utility/IdentifierFlattenerEnumIdTest.php | 14 ++---- .../ORM/Utility/IdentifierFlattenerTest.php | 18 +++----- .../Doctrine/Tests/OrmFunctionalTestCase.php | 41 ++++++++++++++--- 121 files changed, 411 insertions(+), 825 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php b/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php index 3c9d20d40b..8e3da45b4c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\Models\Upsertable\Insertable; use Doctrine\Tests\Models\Upsertable\Updatable; use Doctrine\Tests\OrmFunctionalTestCase; @@ -15,15 +14,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(Updatable::class), - $this->_em->getClassMetadata(Insertable::class), - ] - ); - } catch (ToolsException $e) { - } + $this->createSchemaForModels(Updatable::class, Insertable::class); } public function testNotInsertableIsFetchedFromDatabase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php index e4672d9ffe..dc628a1ef0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php @@ -16,11 +16,9 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(Country::class), - $this->_em->getClassMetadata(CompositeToOneKeyState::class), - ] + $this->createSchemaForModels( + Country::class, + CompositeToOneKeyState::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php index e5b5705c12..5f3720923f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\MappedSuperclass; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\OrmFunctionalTestCase; use function serialize; @@ -22,15 +21,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(MSEFile::class), - $this->_em->getClassMetadata(MSEPicture::class), - ] - ); - } catch (ToolsException $ignored) { - } + $this->createSchemaForModels(MSEFile::class, MSEPicture::class); } public function testMergeSharedNewEntities(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index 2cba6c02a7..a7eef6acf1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -30,10 +30,7 @@ protected function setUp(): void $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8383'); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(NotifyUser::class), - $this->_em->getClassMetadata(NotifyGroup::class), - ]); + $this->createSchemaForModels(NotifyUser::class, NotifyGroup::class); } public function testChangeTracking(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php index 7b1fec871a..763e64dd01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\Models\OneToOneInverseSideLoad\InverseSide; use Doctrine\Tests\Models\OneToOneInverseSideLoad\OwningSide; use Doctrine\Tests\OrmFunctionalTestCase; @@ -17,14 +16,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(OwningSide::class), - $this->_em->getClassMetadata(InverseSide::class), - ]); - } catch (ToolsException $e) { - // ignored - } + $this->createSchemaForModels(OwningSide::class, InverseSide::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index f82d81a596..56e3a74cc7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -98,9 +98,7 @@ public function testLazyLoadsAssociation(): void public function testMultiSelfReference(): void { - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(MultiSelfReference::class), - ]); + $this->createSchemaForModels(MultiSelfReference::class); $entity1 = new MultiSelfReference(); $this->_em->persist($entity1); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php index e3b4ed621b..b433be59d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php @@ -17,11 +17,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(Pet::class), - $this->_em->getClassMetadata(Cat::class), - $this->_em->getClassMetadata(LitterBox::class), - ]); + $this->createSchemaForModels( + Pet::class, + Cat::class, + LitterBox::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index 71755a2164..486805741c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -27,11 +27,11 @@ class OrderedJoinedTableInheritanceCollectionTest extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(OJTICPet::class), - $this->_em->getClassMetadata(OJTICCat::class), - $this->_em->getClassMetadata(OJTICDog::class), - ]); + $this->createSchemaForModels( + OJTICPet::class, + OJTICCat::class, + OJTICDog::class + ); $dog = new OJTICDog(); $dog->name = 'Poofy'; diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 908ca79029..f828b5ab06 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Tools; use Doctrine\Tests\OrmFunctionalTestCase; use function array_filter; @@ -16,28 +15,16 @@ class DBAL483Test extends OrmFunctionalTestCase { - /** @var Tools\SchemaTool */ - private $schemaTool; - - protected function setUp(): void - { - parent::setUp(); - - $this->_em->getConnection(); - - $this->schemaTool = new Tools\SchemaTool($this->_em); - } - /** * @group DBAL-483 */ public function testDefaultValueIsComparedCorrectly(): void { - $class = $this->_em->getClassMetadata(DBAL483Default::class); + $class = DBAL483Default::class; - $this->schemaTool->createSchema([$class]); + $this->createSchemaForModels($class); - $updateSql = $this->schemaTool->getUpdateSchemaSql([$class]); + $updateSql = $this->getUpdateSchemaSqlForModels($class); $updateSql = array_filter($updateSql, static function ($sql) { return str_contains($sql, 'DBAL483'); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index a0690ec236..e1a4b4078a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -6,10 +6,8 @@ use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Comparator; -use Doctrine\ORM\Tools; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function array_filter; use function implode; @@ -23,12 +21,6 @@ */ class DDC214Test extends OrmFunctionalTestCase { - /** @psalm-var list */ - private $classes = []; - - /** @var Tools\SchemaTool */ - private $schemaTool = null; - protected function setUp(): void { parent::setUp(); @@ -38,8 +30,6 @@ protected function setUp(): void if ($conn->getDriver()->getDatabasePlatform() instanceof SqlitePlatform) { self::markTestSkipped('SQLite does not support ALTER TABLE statements.'); } - - $this->schemaTool = new Tools\SchemaTool($this->_em); } /** @@ -47,16 +37,14 @@ protected function setUp(): void */ public function testCmsAddressModel(): void { - $this->classes = [ + $this->assertCreatedSchemaNeedsNoUpdates( Models\CMS\CmsUser::class, Models\CMS\CmsPhonenumber::class, Models\CMS\CmsAddress::class, Models\CMS\CmsGroup::class, Models\CMS\CmsArticle::class, - Models\CMS\CmsEmail::class, - ]; - - $this->assertCreatedSchemaNeedsNoUpdates($this->classes); + Models\CMS\CmsEmail::class + ); } /** @@ -64,7 +52,7 @@ public function testCmsAddressModel(): void */ public function testCompanyModel(): void { - $this->classes = [ + $this->assertCreatedSchemaNeedsNoUpdates( Models\Company\CompanyPerson::class, Models\Company\CompanyEmployee::class, Models\Company\CompanyManager::class, @@ -72,29 +60,21 @@ public function testCompanyModel(): void Models\Company\CompanyEvent::class, Models\Company\CompanyAuction::class, Models\Company\CompanyRaffle::class, - Models\Company\CompanyCar::class, - ]; - - $this->assertCreatedSchemaNeedsNoUpdates($this->classes); + Models\Company\CompanyCar::class + ); } - public function assertCreatedSchemaNeedsNoUpdates($classes): void + /** + * @param class-string ...$classes + */ + public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void { - $classMetadata = []; - foreach ($classes as $class) { - $classMetadata[] = $this->_em->getClassMetadata($class); - } - - try { - $this->schemaTool->createSchema($classMetadata); - } catch (Exception $e) { - // was already created - } + $this->createSchemaForModels(...$classes); $sm = $this->createSchemaManager(); $fromSchema = $sm->createSchema(); - $toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata); + $toSchema = $this->getSchemaForModels(...$classes); if (method_exists($sm, 'createComparator')) { $comparator = $sm->createComparator(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 0e5dec78d2..6c3d26ffb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; @@ -44,15 +43,10 @@ public function testPostgresMetadataSequenceIncrementedBy10(): void */ public function testUpdateSchemaWithPostgreSQLSchema(): void { - $classes = [ - $this->_em->getClassMetadata(DDC1657Screen::class), - $this->_em->getClassMetadata(DDC1657Avatar::class), - ]; - - $tool = new SchemaTool($this->_em); - $tool->createSchema($classes); - - $sql = $tool->getUpdateSchemaSql($classes); + $sql = $this->getUpdateSchemaSqlForModels( + DDC1657Screen::class, + DDC1657Avatar::class + ); $sql = array_filter($sql, static function ($sql) { return str_starts_with($sql, 'DROP SEQUENCE stonewood.'); }); diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index 3ac949c12c..c625d4e502 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -23,9 +23,7 @@ protected function setUp(): void 'This test is special to platforms emulating IDENTITY key generation strategy through sequences.' ); } else { - $this->_schemaTool->createSchema( - [$this->_em->getClassMetadata(SequenceEmulatedIdentityEntity::class)] - ); + $this->createSchemaForModels(SequenceEmulatedIdentityEntity::class); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index 0a7da98d5d..cfc6001798 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -24,12 +24,10 @@ class DDC1080Test extends OrmFunctionalTestCase { public function testHydration(): void { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1080Foo::class), - $this->_em->getClassMetadata(DDC1080Bar::class), - $this->_em->getClassMetadata(DDC1080FooBar::class), - ] + $this->createSchemaForModels( + DDC1080Foo::class, + DDC1080Bar::class, + DDC1080FooBar::class ); $foo1 = new DDC1080Foo(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 9ea3d88346..473f6771e7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -36,13 +36,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1163Product::class), - $this->_em->getClassMetadata(DDC1163SpecialProduct::class), - $this->_em->getClassMetadata(DDC1163ProxyHolder::class), - $this->_em->getClassMetadata(DDC1163Tag::class), - ] + $this->createSchemaForModels( + DDC1163Product::class, + DDC1163SpecialProduct::class, + DDC1163ProxyHolder::class, + DDC1163Tag::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index 00cd93cf8f..52ab662d9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -19,12 +19,10 @@ class DDC1181Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1181Hotel::class), - $this->_em->getClassMetadata(DDC1181Booking::class), - $this->_em->getClassMetadata(DDC1181Room::class), - ] + $this->createSchemaForModels( + DDC1181Hotel::class, + DDC1181Booking::class, + DDC1181Room::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index fb8fa3b1a9..63897096a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -19,12 +19,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1193Company::class), - $this->_em->getClassMetadata(DDC1193Person::class), - $this->_em->getClassMetadata(DDC1193Account::class), - ] + $this->createSchemaForModels( + DDC1193Company::class, + DDC1193Person::class, + DDC1193Account::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index 0912bf28e9..3f9655c49d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -23,11 +23,9 @@ class DDC1225Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1225TestEntity1::class), - $this->_em->getClassMetadata(DDC1225TestEntity2::class), - ] + $this->createSchemaForModels( + DDC1225TestEntity1::class, + DDC1225TestEntity2::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 368dba40a3..06998b6baa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -20,9 +20,7 @@ class DDC1250Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [$this->_em->getClassMetadata(DDC1250ClientHistory::class)] - ); + $this->createSchemaForModels(DDC1250ClientHistory::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index 731eecd621..da19f707bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -22,11 +22,9 @@ class DDC1300Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1300Foo::class), - $this->_em->getClassMetadata(DDC1300FooLocale::class), - ] + $this->createSchemaForModels( + DDC1300Foo::class, + DDC1300FooLocale::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php index 828d493d6d..2dd4c5539b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php @@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function get_debug_type; @@ -26,15 +25,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1383AbstractEntity::class), - $this->_em->getClassMetadata(DDC1383Entity::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels( + DDC1383AbstractEntity::class, + DDC1383Entity::class + ); } public function testFailingCase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php index 05744bc93a..8bf1e5cc03 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1392 @@ -23,15 +22,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1392File::class), - $this->_em->getClassMetadata(DDC1392Picture::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels(DDC1392File::class, DDC1392Picture::class); } public function testFailingCase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php index abc8ab68d6..5e1bf6b85a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1400 @@ -23,16 +22,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1400Article::class), - $this->_em->getClassMetadata(DDC1400User::class), - $this->_em->getClassMetadata(DDC1400UserState::class), - ] + $this->createSchemaForModels( + DDC1400Article::class, + DDC1400User::class, + DDC1400UserState::class ); - } catch (Exception $ignored) { - } } public function testFailingCase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php index 90c24e6b34..45b236da27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php @@ -25,17 +25,12 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1404ParentEntity::class), - $this->_em->getClassMetadata(DDC1404ChildEntity::class), - ] - ); - - $this->loadFixtures(); - } catch (Exception $exc) { - } + $this->createSchemaForModels( + DDC1404ParentEntity::class, + DDC1404ChildEntity::class + ); + + $this->loadFixtures(); } public function testTicket(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index 8b62c7a4a7..79c30c2f98 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1436 @@ -22,14 +21,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1436Page::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels(DDC1436Page::class); } public function testIdentityMap(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php index a9832db5f3..c4ac7cf3b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -20,11 +20,9 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC144FlowElement::class), - $this->_em->getClassMetadata(DDC144Operand::class), - ] + $this->createSchemaForModels( + DDC144FlowElement::class, + DDC144Operand::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 29ee1f119b..5aa90545af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -16,7 +16,6 @@ use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1452 @@ -28,15 +27,10 @@ protected function setUp(): void $this->useModelSet('cms'); parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1452EntityA::class), - $this->_em->getClassMetadata(DDC1452EntityB::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels( + DDC1452EntityA::class, + DDC1452EntityB::class + ); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index a15259b875..dca5670966 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function getrandmax; use function random_int; @@ -26,15 +25,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1454File::class), - $this->_em->getClassMetadata(DDC1454Picture::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels(DDC1454File::class, DDC1454Picture::class); } public function testFailingCase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php index 9c1cda103f..86b330d93d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -16,11 +16,9 @@ class DDC1458Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(TestEntity::class), - $this->_em->getClassMetadata(TestAdditionalEntity::class), - ] + $this->createSchemaForModels( + TestEntity::class, + TestAdditionalEntity::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php index 10ba0c85ba..a5a8ceb8a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function assert; @@ -27,16 +26,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1509AbstractFile::class), - $this->_em->getClassMetadata(DDC1509File::class), - $this->_em->getClassMetadata(DDC1509Picture::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels( + DDC1509AbstractFile::class, + DDC1509File::class, + DDC1509Picture::class + ); } public function testFailingCase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index 41cf8418aa..4de542f1ea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1514 @@ -24,16 +23,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1514EntityA::class), - $this->_em->getClassMetadata(DDC1514EntityB::class), - $this->_em->getClassMetadata(DDC1514EntityC::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels( + DDC1514EntityA::class, + DDC1514EntityB::class, + DDC1514EntityC::class + ); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index 00249e6e75..d8268f9ef8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -19,11 +19,9 @@ class DDC1515Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1515Foo::class), - $this->_em->getClassMetadata(DDC1515Bar::class), - ] + $this->createSchemaForModels( + DDC1515Foo::class, + DDC1515Bar::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index 9c0cdfea0c..380bdbd075 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -21,11 +21,7 @@ class DDC1526Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1526Menu::class), - ] - ); + $this->createSchemaForModels(DDC1526Menu::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index ebb0405deb..0486813fef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -19,12 +19,10 @@ class DDC1548Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1548E1::class), - $this->_em->getClassMetadata(DDC1548E2::class), - $this->_em->getClassMetadata(DDC1548Rel::class), - ] + $this->createSchemaForModels( + DDC1548E1::class, + DDC1548E2::class, + DDC1548Rel::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index f4ab7b3394..e7387a4a2c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -29,12 +29,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1595BaseInheritance::class), - $this->_em->getClassMetadata(DDC1595InheritedEntity1::class), - $this->_em->getClassMetadata(DDC1595InheritedEntity2::class), - ] + $this->createSchemaForModels( + DDC1595BaseInheritance::class, + DDC1595InheritedEntity1::class, + DDC1595InheritedEntity2::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index 5a3bceb3c9..23cdcb3b34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -23,10 +23,7 @@ class DDC1690Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(DDC1690Parent::class), - $this->_em->getClassMetadata(DDC1690Child::class), - ]); + $this->createSchemaForModels(DDC1690Parent::class, DDC1690Child::class); } public function testChangeTracking(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index 3db0472597..7ffb3768a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\PostLoad; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1707 @@ -25,15 +24,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1509File::class), - $this->_em->getClassMetadata(DDC1509Picture::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels( + DDC1707Base::class, + DDC1707Child::class + ); } public function testPostLoadOnChild(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 8392c5ce19..923b764192 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -22,11 +22,9 @@ class DDC1787Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1787Foo::class), - $this->_em->getClassMetadata(DDC1787Bar::class), - ] + $this->createSchemaForModels( + DDC1787Foo::class, + DDC1787Bar::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index 85dda67e71..4f1f070ab3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -26,12 +26,7 @@ class DDC1925Test extends OrmFunctionalTestCase { public function testIssue(): void { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1925User::class), - $this->_em->getClassMetadata(DDC1925Product::class), - ] - ); + $this->createSchemaForModels(DDC1925User::class, DDC1925Product::class); $user = new DDC1925User(); $user->setTitle('Test User'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php index 00997f84f2..8ce2ce3c67 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -14,8 +13,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use function assert; - /** * @group DDC-192 */ @@ -24,17 +21,19 @@ class DDC192Test extends OrmFunctionalTestCase public function testSchemaCreation(): void { $classes = [ - $this->_em->getClassMetadata(DDC192User::class), - $this->_em->getClassMetadata(DDC192Phonenumber::class), + DDC192User::class, + DDC192Phonenumber::class, ]; - $this->_schemaTool->createSchema($classes); + $this->createSchemaForModels(...$classes); $tables = $this->createSchemaManager()->listTableNames(); foreach ($classes as $class) { - assert($class instanceof ClassMetadata); - self::assertContains($class->getTableName(), $tables); + self::assertContains( + $this->_em->getClassMetadata($class)->getTableName(), + $tables + ); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 9e1fda26b1..06b011c3cc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -21,11 +21,7 @@ public function testSqlConversionAsIdentifier(): void { Type::addType('ddc1998', DDC1998Type::class); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1998Entity::class), - ] - ); + $this->createSchemaForModels(DDC1998Entity::class); $entity = new DDC1998Entity(); $entity->id = new DDC1998Id('foo'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php index de7d3c19c7..cd2a28c12d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -23,12 +23,10 @@ class DDC199Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC199ParentClass::class), - $this->_em->getClassMetadata(DDC199ChildClass::class), - $this->_em->getClassMetadata(DDC199RelatedClass::class), - ] + $this->createSchemaForModels( + DDC199ParentClass::class, + DDC199ChildClass::class, + DDC199RelatedClass::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index 668e5e3d66..08ff1abb9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -37,11 +37,9 @@ protected function setUp(): void DDC2012TsVectorType::$calls = []; - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2012Item::class), - $this->_em->getClassMetadata(DDC2012ItemPerson::class), - ] + $this->createSchemaForModels( + DDC2012Item::class, + DDC2012ItemPerson::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index 672ec19b61..599dac09bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-2084 @@ -16,15 +15,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2084\MyEntity1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2084\MyEntity2'), - ] - ); - } catch (Exception $exc) { - } + $this->createSchemaForModels( + __NAMESPACE__ . '\DDC2084\MyEntity1', + __NAMESPACE__ . '\DDC2084\MyEntity2' + ); } public function loadFixture(): DDC2084\MyEntity1 diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php index c3acf8effe..6cf927bdbf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php @@ -24,11 +24,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2106Entity::class), - ] - ); + $this->createSchemaForModels(DDC2106Entity::class); } public function testDetachedEntityAsId(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php index e25094fca3..40aab51ed0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -21,12 +21,7 @@ class DDC211Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC211User::class), - $this->_em->getClassMetadata(DDC211Group::class), - ] - ); + $this->createSchemaForModels(DDC211User::class, DDC211Group::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 098b9c78a3..6bb573ee0e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -18,7 +18,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmFunctionalTestCase; use function assert; @@ -31,18 +30,14 @@ class DDC2138Test extends OrmFunctionalTestCase */ public function testForeignKeyOnSTIWithMultipleMapping(): void { - $em = $this->_em; - $schemaTool = new SchemaTool($em); - - $classes = [ - $em->getClassMetadata(DDC2138User::class), - $em->getClassMetadata(DDC2138Structure::class), - $em->getClassMetadata(DDC2138UserFollowedObject::class), - $em->getClassMetadata(DDC2138UserFollowedStructure::class), - $em->getClassMetadata(DDC2138UserFollowedUser::class), - ]; - - $schema = $schemaTool->getSchemaFromMetadata($classes); + $em = $this->_em; + $schema = $this->getSchemaForModels( + DDC2138User::class, + DDC2138Structure::class, + DDC2138UserFollowedObject::class, + DDC2138UserFollowedStructure::class, + DDC2138UserFollowedUser::class + ); self::assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.'); $table = $schema->getTable('users_followed_objects'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 44a8dfff4a..86ec2d0621 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -21,11 +21,7 @@ class DDC2175Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2175Entity::class), - ] - ); + $this->createSchemaForModels(DDC2175Entity::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 5ba1d389a5..ce246fd1af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -30,12 +30,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2214Foo::class), - $this->_em->getClassMetadata(DDC2214Bar::class), - ] - ); + $this->createSchemaForModels(DDC2214Foo::class, DDC2214Bar::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index c8025dc6dc..e9f130889c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Persistence\NotifyPropertyChanged; use Doctrine\Persistence\PropertyChangedListener; use Doctrine\Tests\OrmFunctionalTestCase; @@ -27,15 +26,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2230User::class), - $this->_em->getClassMetadata(DDC2230Address::class), - ] - ); - } catch (ToolsException $e) { - } + $this->createSchemaForModels( + DDC2230User::class, + DDC2230Address::class + ); } public function testNotifyTrackingNotCalledOnUninitializedProxies(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php index 23186bb079..0431e631b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php @@ -30,11 +30,7 @@ protected function setUp(): void } parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2231EntityY::class), - ] - ); + $this->createSchemaForModels(DDC2231EntityY::class); } public function testInjectObjectManagerInProxyIfInitializedInUow(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index 3fa9b6488e..b98f7d7858 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -40,13 +40,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2252User::class), - $this->_em->getClassMetadata(DDC2252Privilege::class), - $this->_em->getClassMetadata(DDC2252Membership::class), - $this->_em->getClassMetadata(DDC2252MerchantAccount::class), - ] + $this->createSchemaForModels( + DDC2252User::class, + DDC2252Privilege::class, + DDC2252Membership::class, + DDC2252MerchantAccount::class ); $this->loadFixtures(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php index 57a5712a2f..dc61f8a425 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php @@ -33,11 +33,9 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2256User::class), - $this->_em->getClassMetadata(DDC2256Group::class), - ] + $this->createSchemaForModels( + DDC2256User::class, + DDC2256Group::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 53b51bebde..73282c590d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -26,13 +26,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2306Zone::class), - $this->_em->getClassMetadata(DDC2306User::class), - $this->_em->getClassMetadata(DDC2306Address::class), - $this->_em->getClassMetadata(DDC2306UserAddress::class), - ] + $this->createSchemaForModels( + DDC2306Zone::class, + DDC2306User::class, + DDC2306Address::class, + DDC2306UserAddress::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 855c0fc1b5..0dc4a79a95 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -26,12 +26,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2346Foo::class), - $this->_em->getClassMetadata(DDC2346Bar::class), - $this->_em->getClassMetadata(DDC2346Baz::class), - ] + $this->createSchemaForModels( + DDC2346Foo::class, + DDC2346Bar::class, + DDC2346Baz::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index 017464b065..5eb1aaacce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -23,12 +23,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2350User::class), - $this->_em->getClassMetadata(DDC2350Bug::class), - ] - ); + $this->createSchemaForModels(DDC2350User::class, DDC2350Bug::class); } public function testEagerCollectionsAreOnlyRetrievedOnce(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index d68112a589..bd914c6808 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -21,12 +21,10 @@ class DDC237Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC237EntityX::class), - $this->_em->getClassMetadata(DDC237EntityY::class), - $this->_em->getClassMetadata(DDC237EntityZ::class), - ] + $this->createSchemaForModels( + DDC237EntityX::class, + DDC237EntityY::class, + DDC237EntityZ::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index b99b56bdc7..efacd5f2a3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -23,11 +23,9 @@ protected function setUp(): void $this->_em->getConfiguration()->setMetadataDriverImpl(new StaticPHPDriver([])); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2415ParentEntity::class), - $this->_em->getClassMetadata(DDC2415ChildEntity::class), - ] + $this->createSchemaForModels( + DDC2415ParentEntity::class, + DDC2415ChildEntity::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index 865699a52e..61f972f55d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -31,11 +31,9 @@ protected function setUp(): void Type::addType('ddc2494_tinyint', DDC2494TinyIntType::class); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2494Currency::class), - $this->_em->getClassMetadata(DDC2494Campaign::class), - ] + $this->createSchemaForModels( + DDC2494Currency::class, + DDC2494Campaign::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index 762704d232..58ae84d7c1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -30,12 +30,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2575Root::class), - $this->_em->getClassMetadata(DDC2575A::class), - $this->_em->getClassMetadata(DDC2575B::class), - ] + $this->createSchemaForModels( + DDC2575Root::class, + DDC2575A::class, + DDC2575B::class ); $entityRoot1 = new DDC2575Root(1); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 053680fbe8..d5ac1e9df4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -25,12 +25,10 @@ protected function setUp(): void Type::addType(DDC2579Type::NAME, DDC2579Type::class); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2579Entity::class), - $this->_em->getClassMetadata(DDC2579EntityAssoc::class), - $this->_em->getClassMetadata(DDC2579AssocAssoc::class), - ] + $this->createSchemaForModels( + DDC2579Entity::class, + DDC2579EntityAssoc::class, + DDC2579AssocAssoc::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index f3760a86a5..50780e3403 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -19,13 +19,11 @@ class DDC258Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC258Super::class), - $this->_em->getClassMetadata(DDC258Class1::class), - $this->_em->getClassMetadata(DDC258Class2::class), - $this->_em->getClassMetadata(DDC258Class3::class), - ] + $this->createSchemaForModels( + DDC258Super::class, + DDC258Class1::class, + DDC258Class2::class, + DDC258Class3::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index 018eb97c6d..c31b38bdba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-2692 @@ -24,15 +23,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2692Foo::class), - ] - ); - } catch (Exception $e) { - return; - } + $this->createSchemaForModels(DDC2692Foo::class); $this->_em->clear(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index e4ad9f7861..20e078c4dc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-2759 @@ -25,18 +24,12 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2759Qualification::class), - $this->_em->getClassMetadata(DDC2759Category::class), - $this->_em->getClassMetadata(DDC2759QualificationMetadata::class), - $this->_em->getClassMetadata(DDC2759MetadataCategory::class), - ] - ); - } catch (Exception $e) { - return; - } + $this->createSchemaForModels( + DDC2759Qualification::class, + DDC2759Category::class, + DDC2759QualificationMetadata::class, + DDC2759MetadataCategory::class + ); $qualification = new DDC2759Qualification(); $qualificationMetadata = new DDC2759QualificationMetadata($qualification); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 0c8a216648..64b8536d34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -22,12 +22,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2780User::class), - $this->_em->getClassMetadata(DDC2780Project::class), - ] - ); + $this->createSchemaForModels(DDC2780User::class, DDC2780Project::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index 56b44c6cc1..be955bc016 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -20,13 +20,11 @@ class DDC279Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC279EntityXAbstract::class), - $this->_em->getClassMetadata(DDC279EntityX::class), - $this->_em->getClassMetadata(DDC279EntityY::class), - $this->_em->getClassMetadata(DDC279EntityZ::class), - ] + $this->createSchemaForModels( + DDC279EntityXAbstract::class, + DDC279EntityX::class, + DDC279EntityY::class, + DDC279EntityZ::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index e36f7d5690..171856acfb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable; use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName; use Doctrine\Tests\OrmFunctionalTestCase; @@ -68,11 +67,7 @@ public function testClassSchemaMappingsValidity(string $className, string $expec */ public function testPersistenceOfEntityWithSchemaMapping(string $className): void { - try { - $this->_schemaTool->createSchema([$this->_em->getClassMetadata($className)]); - } catch (ToolsException $e) { - // table already exists - } + $this->createSchemaForModels($className); $this->_em->persist(new $className()); $this->_em->flush(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index d90032665c..eb14793af8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\OrmFunctionalTestCase; /** @@ -25,15 +24,7 @@ protected function setUp(): void $this->enableSecondLevelCache(); parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2862User::class), - $this->_em->getClassMetadata(DDC2862Driver::class), - ] - ); - } catch (ToolsException $exc) { - } + $this->createSchemaForModels(DDC2862User::class, DDC2862Driver::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index 9d198a42aa..820b4c1a80 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-2931 @@ -22,15 +21,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2931User::class), - ] - ); - } catch (Exception $e) { - // no action needed - schema seems to be already in place - } + $this->createSchemaForModels(DDC2931User::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 855611b1f6..bd24c32ebc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function is_string; @@ -34,15 +33,7 @@ protected function setUp(): void ); } - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2984User::class), - ] - ); - } catch (Exception $e) { - // no action needed - schema seems to be already in place - } + $this->createSchemaForModels(DDC2984User::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 60f808833a..5f54e78ee7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -22,11 +22,9 @@ class DDC2996Test extends OrmFunctionalTestCase { public function testIssue(): void { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2996User::class), - $this->_em->getClassMetadata(DDC2996UserPreference::class), - ] + $this->createSchemaForModels( + DDC2996User::class, + DDC2996UserPreference::class ); $pref = new DDC2996UserPreference(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index b646e7fcf1..5b3263dde7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -29,11 +29,9 @@ class DDC3033Test extends OrmFunctionalTestCase { public function testIssue(): void { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3033User::class), - $this->_em->getClassMetadata(DDC3033Product::class), - ] + $this->createSchemaForModels( + DDC3033User::class, + DDC3033Product::class ); $user = new DDC3033User(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index 9959772710..7c77a32475 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -19,12 +19,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3042Foo::class), - $this->_em->getClassMetadata(DDC3042Bar::class), - ] - ); + $this->createSchemaForModels(DDC3042Foo::class, DDC3042Bar::class); } public function testSQLGenerationDoesNotProvokeAliasCollisions(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php index a2586a2e6a..6dcdbaaeb4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php @@ -23,13 +23,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3170AbstractEntityJoined::class), - $this->_em->getClassMetadata(DDC3170ProductJoined::class), - $this->_em->getClassMetadata(DDC3170AbstractEntitySingleTable::class), - $this->_em->getClassMetadata(DDC3170ProductSingleTable::class), - ] + $this->createSchemaForModels( + DDC3170AbstractEntityJoined::class, + DDC3170ProductJoined::class, + DDC3170AbstractEntitySingleTable::class, + DDC3170ProductSingleTable::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index d8f8a30efd..bf73cfab43 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -38,11 +38,9 @@ protected function setUp(): void Type::addType('ddc3192_currency_code', DDC3192CurrencyCode::class); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3192Currency::class), - $this->_em->getClassMetadata(DDC3192Transaction::class), - ] + $this->createSchemaForModels( + DDC3192Currency::class, + DDC3192Transaction::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index 8cc3a11b4c..b919c10504 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -37,11 +37,7 @@ public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void $this->_em->getEventManager()->addEventSubscriber($resolveTargetEntity); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3300Person::class), - ] - ); + $this->createSchemaForModels(DDC3300Person::class); $boss = new DDC3300HumanBoss('boss'); $employee = new DDC3300HumanEmployee('employee'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index 24a9d3bd8a..cb5dbc9ec3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -20,7 +20,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([$this->_em->getClassMetadata(DDC3303Employee::class)]); + $this->createSchemaForModels(DDC3303Employee::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index 8f4bb30875..54a1b4b602 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -27,12 +27,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC345User::class), - $this->_em->getClassMetadata(DDC345Group::class), - $this->_em->getClassMetadata(DDC345Membership::class), - ] + $this->createSchemaForModels( + DDC345User::class, + DDC345Group::class, + DDC345Membership::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index c209ca1b94..888464558b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -13,22 +13,13 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC353Test extends OrmFunctionalTestCase { protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC353File::class), - $this->_em->getClassMetadata(DDC353Picture::class), - ] - ); - } catch (Exception $ignored) { - } + $this->createSchemaForModels(DDC353File::class, DDC353Picture::class); } public function testWorkingCase(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index a301b2fbf2..d4a0fa9592 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -17,7 +17,7 @@ class DDC3582Test extends OrmFunctionalTestCase { public function testNestedEmbeddablesAreHydratedWithProperClass(): void { - $this->_schemaTool->createSchema([$this->_em->getClassMetadata(DDC3582Entity::class)]); + $this->createSchemaForModels(DDC3582Entity::class); $this->_em->persist(new DDC3582Entity('foo')); $this->_em->flush(); $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php index d7f200166c..b20466f41b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php @@ -17,12 +17,10 @@ class DDC3597Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3597Root::class), - $this->_em->getClassMetadata(DDC3597Media::class), - $this->_em->getClassMetadata(DDC3597Image::class), - ] + $this->createSchemaForModels( + DDC3597Root::class, + DDC3597Media::class, + DDC3597Image::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index ae5b364eb7..6e558ac48c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\OrmFunctionalTestCase; use function call_user_func_array; @@ -40,15 +39,11 @@ protected function setUp(): void self::markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); } - try { - $this->_schemaTool->createSchema([ - $metadata, - $this->_em->getClassMetadata(DDC3634JTIBaseEntity::class), - $this->_em->getClassMetadata(DDC3634JTIChildEntity::class), - ]); - } catch (ToolsException $e) { - // schema already in place - } + $this->createSchemaForModels( + DDC3634Entity::class, + DDC3634JTIBaseEntity::class, + DDC3634JTIChildEntity::class + ); } public function testSavesVeryLargeIntegerAutoGeneratedValue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 8f1792b6e7..05acb7f9a7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -26,12 +26,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC371Parent::class), - $this->_em->getClassMetadata(DDC371Child::class), - ] - ); + $this->createSchemaForModels(DDC371Parent::class, DDC371Child::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 849cd85602..a83eeeac9f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -27,12 +27,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC422Guest::class), - $this->_em->getClassMetadata(DDC422Customer::class), - $this->_em->getClassMetadata(DDC422Contact::class), - ] + $this->createSchemaForModels( + DDC422Guest::class, + DDC422Customer::class, + DDC422Contact::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index d3e72ccff3..bdd852d213 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -17,11 +17,7 @@ class DDC425Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC425Entity::class), - ] - ); + $this->createSchemaForModels(DDC425Entity::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index 42e20642a1..89c0a2c0dc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -23,10 +23,7 @@ class DDC440Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(DDC440Phone::class), - $this->_em->getClassMetadata(DDC440Client::class), - ]); + $this->createSchemaForModels(DDC440Phone::class, DDC440Client::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php index 8fec28cedc..81b595b37a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php @@ -20,11 +20,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC444User::class), - ] - ); + $this->createSchemaForModels(DDC444User::class); } public function testExplicitPolicy(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index 8b30908b87..d9e415ceae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -24,12 +24,10 @@ class DDC448Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC448MainTable::class), - $this->_em->getClassMetadata(DDC448ConnectedClass::class), - $this->_em->getClassMetadata(DDC448SubTable::class), - ] + $this->createSchemaForModels( + DDC448MainTable::class, + DDC448ConnectedClass::class, + DDC448SubTable::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php index fd99cc6d5c..794af8187f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -22,12 +22,10 @@ class DDC493Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC493Customer::class), - $this->_em->getClassMetadata(DDC493Distributor::class), - $this->_em->getClassMetadata(DDC493Contact::class), - ] + $this->createSchemaForModels( + DDC493Customer::class, + DDC493Distributor::class, + DDC493Contact::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php index 637a7ea865..da8d3c7350 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -20,12 +20,10 @@ class DDC512Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC512Customer::class), - $this->_em->getClassMetadata(DDC512OfferItem::class), - $this->_em->getClassMetadata(DDC512Item::class), - ] + $this->createSchemaForModels( + DDC512Customer::class, + DDC512OfferItem::class, + DDC512Item::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php index ef0856f507..e26b8bfe11 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -22,12 +22,10 @@ class DDC513Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC513OfferItem::class), - $this->_em->getClassMetadata(DDC513Item::class), - $this->_em->getClassMetadata(DDC513Price::class), - ] + $this->createSchemaForModels( + DDC513OfferItem::class, + DDC513Item::class, + DDC513Price::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php index d6d0ada427..d9299555d8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -24,11 +24,9 @@ class DDC531Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC531Item::class), - $this->_em->getClassMetadata(DDC531SubItem::class), - ] + $this->createSchemaForModels( + DDC531Item::class, + DDC531SubItem::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index e09a0f4bd8..429b770fcd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -16,11 +16,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC588Site::class), - ] - ); + $this->createSchemaForModels(DDC588Site::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 6252574748..67b9a88378 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC599Test extends OrmFunctionalTestCase { @@ -25,16 +24,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC599Item::class), - $this->_em->getClassMetadata(DDC599Subitem::class), - $this->_em->getClassMetadata(DDC599Child::class), - ] + $this->createSchemaForModels( + DDC599Item::class, + DDC599Subitem::class, + DDC599Child::class ); - } catch (Exception $ignored) { - } } public function testCascadeRemoveOnInheritanceHierarchy(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index 504edfa261..f302a7977a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\OptimisticLockException; -use Doctrine\ORM\Tools\ToolsException; use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Tests\OrmFunctionalTestCase; @@ -31,14 +30,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(DDC6303BaseClass::class), - $this->_em->getClassMetadata(DDC6303ChildA::class), - $this->_em->getClassMetadata(DDC6303ChildB::class), - ]); - } catch (ToolsException $ignored) { - } + $this->createSchemaForModels( + DDC6303BaseClass::class, + DDC6303ChildA::class, + DDC6303ChildB::class + ); } public function testMixedTypeHydratedCorrectlyInJoinedInheritance(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index 71dbf66510..367409ba13 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -24,11 +24,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC719Group::class), - ] - ); + $this->createSchemaForModels(DDC719Group::class); } public function testIsEmptySqlGeneration(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index 102cace4b4..dd85e0345e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -19,11 +19,9 @@ class DDC809Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC809Variant::class), - $this->_em->getClassMetadata(DDC809SpecificationValue::class), - ] + $this->createSchemaForModels( + DDC809Variant::class, + DDC809SpecificationValue::class ); $conn = $this->_em->getConnection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index 5b9fc04bae..59189a2bec 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -20,14 +20,12 @@ class DDC837Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC837Super::class), - $this->_em->getClassMetadata(DDC837Class1::class), - $this->_em->getClassMetadata(DDC837Class2::class), - $this->_em->getClassMetadata(DDC837Class3::class), - $this->_em->getClassMetadata(DDC837Aggregate::class), - ] + $this->createSchemaForModels( + DDC837Super::class, + DDC837Class1::class, + DDC837Class2::class, + DDC837Class3::class, + DDC837Aggregate::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 333f98a9f7..75868237f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -24,7 +24,7 @@ protected function setUp(): void parent::setUp(); - $this->_schemaTool->createSchema([$this->_em->getClassMetadata(GH2947Car::class)]); + $this->createSchemaForModels(GH2947Car::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 849b0ab77e..bbff675432 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -24,12 +24,10 @@ protected function setUp(): void parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(GH5562User::class), - $this->_em->getClassMetadata(GH5562Manager::class), - $this->_em->getClassMetadata(GH5562Merchant::class), - ] + $this->createSchemaForModels( + GH5562User::class, + GH5562Manager::class, + GH5562Merchant::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index c59a0c44c8..7c77eb6bdb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -29,12 +29,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(GH5762Driver::class), - $this->_em->getClassMetadata(GH5762DriverRide::class), - $this->_em->getClassMetadata(GH5762Car::class), - ] + $this->createSchemaForModels( + GH5762Driver::class, + GH5762DriverRide::class, + GH5762Car::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index 3b4b1df8d9..fdce61601e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -27,9 +27,7 @@ protected function setUp(): void Type::addType(GH5804Type::NAME, GH5804Type::class); - $this->_schemaTool->createSchema( - [$this->_em->getClassMetadata(GH5804Article::class)] - ); + $this->createSchemaForModels(GH5804Article::class); } public function testTextColumnSaveAndRetrieve2(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index 845f35ef0b..d04279d621 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -28,12 +28,7 @@ protected function setUp(): void Type::addType(GH5887CustomIdObjectType::NAME, GH5887CustomIdObjectType::class); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(GH5887Cart::class), - $this->_em->getClassMetadata(GH5887Customer::class), - ] - ); + $this->createSchemaForModels(GH5887Cart::class, GH5887Customer::class); } public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomIdObject(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index e4a4f2e5c5..7ec6042c1c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -28,12 +28,10 @@ protected function setUp(): void Type::addType(GH6141PeopleType::NAME, GH6141PeopleType::class); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(GH6141Person::class), - $this->_em->getClassMetadata(GH6141Boss::class), - $this->_em->getClassMetadata(GH6141Employee::class), - ] + $this->createSchemaForModels( + GH6141Person::class, + GH6141Boss::class, + GH6141Employee::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index 9e3b2edebe..d718ef4b16 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Doctrine\Tests\Functional\Ticket; +namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\ORM\Mapping\Cache; use Doctrine\ORM\Mapping\Column; @@ -25,10 +25,10 @@ protected function setUp(): void parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(GH6217AssociatedEntity::class), - $this->_em->getClassMetadata(GH6217FetchedEntity::class), - ]); + $this->createSchemaForModels( + GH6217AssociatedEntity::class, + GH6217FetchedEntity::class + ); } public function testLoadingOfSecondLevelCacheOnEagerAssociations(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 5647c67687..c123281a89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -26,13 +26,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(GH6362Start::class), - $this->_em->getClassMetadata(GH6362Base::class), - $this->_em->getClassMetadata(GH6362Child::class), - $this->_em->getClassMetadata(GH6362Join::class), - ] + $this->createSchemaForModels( + GH6362Start::class, + GH6362Base::class, + GH6362Child::class, + GH6362Join::class ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index d7bb5f8d6c..a5392abe18 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -18,12 +18,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(A::class), - $this->_em->getClassMetadata(B::class), - ] - ); + $this->createSchemaForModels(A::class, B::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index 062d932c34..838015bb3b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -22,11 +22,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(GH6464Post::class), - $this->_em->getClassMetadata(GH6464User::class), - $this->_em->getClassMetadata(GH6464Author::class), - ]); + $this->createSchemaForModels( + GH6464Post::class, + GH6464User::class, + GH6464Author::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php index 82d1282b97..6cad790dd1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php @@ -22,12 +22,10 @@ protected function setUp(): void $this->enableSecondLevelCache(); parent::setUp(); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(GH7735Car::class), - $this->_em->getClassMetadata(GH7735Power::class), - $this->_em->getClassMetadata(GH7735Engine::class), - ] + $this->createSchemaForModels( + GH7735Car::class, + GH7735Power::class, + GH7735Engine::class ); $this->_em->persist(new GH7735Car(1, new GH7735Engine(1, 'turbo', new GH7735Power(1)))); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index ba7908f458..23917dfbd7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmFunctionalTestCase; use function array_filter; @@ -53,24 +52,23 @@ private function filterCreateTable(array $sqls, string $tableName): array public function testUpdateSchemaSql(): void { - $classes = [$this->_em->getClassMetadata(GH7875MyEntity::class)]; + $classes = [GH7875MyEntity::class]; - $tool = new SchemaTool($this->_em); - $sqls = $this->filterCreateTable($tool->getUpdateSchemaSql($classes), 'gh7875_my_entity'); + $sqls = $this->filterCreateTable($this->getUpdateSchemaSqlForModels(...$classes), 'gh7875_my_entity'); self::assertCount(1, $sqls); $this->_em->getConnection()->executeStatement(current($sqls)); - $sqls = array_filter($tool->getUpdateSchemaSql($classes), static function (string $sql): bool { + $sqls = array_filter($this->getUpdateSchemaSqlForModels(...$classes), static function (string $sql): bool { return str_contains($sql, ' gh7875_my_entity '); }); self::assertSame([], $sqls); - $classes[] = $this->_em->getClassMetadata(GH7875MyOtherEntity::class); + $classes[] = GH7875MyOtherEntity::class; - $sqls = $tool->getUpdateSchemaSql($classes); + $sqls = $this->getUpdateSchemaSqlForModels(...$classes); self::assertCount(0, $this->filterCreateTable($sqls, 'gh7875_my_entity')); self::assertCount(1, $this->filterCreateTable($sqls, 'gh7875_my_other_entity')); @@ -99,10 +97,9 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(?string $filterRegex, ? self::markTestSkipped(sprintf('Test require %s::setFilterSchemaAssetsExpression method', Configuration::class)); } - $classes = [$this->_em->getClassMetadata(GH7875MyEntity::class)]; + $class = GH7875MyEntity::class; - $tool = new SchemaTool($this->_em); - $tool->createSchema($classes); + $this->createSchemaForModels($class); $config = $this->_em->getConnection()->getConfiguration(); if ($filterRegex) { @@ -113,7 +110,7 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(?string $filterRegex, ? $previousFilter = $config->getSchemaAssetsFilter(); - $sqls = $tool->getUpdateSchemaSql($classes); + $sqls = $this->getUpdateSchemaSqlForModels($class); $sqls = array_filter($sqls, static function (string $sql): bool { return str_contains($sql, ' gh7875_my_entity '); }); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php index 8fb3b0c245..b1702fbaf1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php @@ -17,9 +17,7 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(Ticket2481Product::class), - ]); + $this->createSchemaForModels(Ticket2481Product::class); } public function testEmptyInsert(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php index ecfecf7b7d..7903fe0827 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php @@ -20,10 +20,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(PersonTicket4646Abstract::class), - $this->_em->getClassMetadata(EmployeeTicket4646Abstract::class), - ]); + $this->createSchemaForModels( + PersonTicket4646Abstract::class, + EmployeeTicket4646Abstract::class + ); } public function testInstanceOf(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php index 3ed6574c4d..612052fa64 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php @@ -20,11 +20,11 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(PersonTicket4646MultiLevel::class), - $this->_em->getClassMetadata(EmployeeTicket4646MultiLevel::class), - $this->_em->getClassMetadata(EngineerTicket4646MultiLevel::class), - ]); + $this->createSchemaForModels( + PersonTicket4646MultiLevel::class, + EmployeeTicket4646MultiLevel::class, + EngineerTicket4646MultiLevel::class + ); } public function testInstanceOf(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php index 38b938ce02..56190575ec 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php @@ -19,10 +19,10 @@ class Ticket4646InstanceOfParametricTest extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(PersonTicket4646Parametric::class), - $this->_em->getClassMetadata(EmployeeTicket4646Parametric::class), - ]); + $this->createSchemaForModels( + PersonTicket4646Parametric::class, + EmployeeTicket4646Parametric::class + ); } public function testInstanceOf(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php index 643f286a48..865f38b7ad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php @@ -20,10 +20,10 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(PersonTicket4646::class), - $this->_em->getClassMetadata(EmployeeTicket4646::class), - ]); + $this->createSchemaForModels( + PersonTicket4646::class, + EmployeeTicket4646::class + ); } public function testInstanceOf(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php index 702d2e8a3f..50dce0475d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php @@ -20,12 +20,12 @@ protected function setUp(): void { parent::setUp(); - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(PersonTicket4646Multiple::class), - $this->_em->getClassMetadata(EmployeeTicket4646Multiple::class), - $this->_em->getClassMetadata(ManagerTicket4646Multiple::class), - $this->_em->getClassMetadata(InternTicket4646Multiple::class), - ]); + $this->createSchemaForModels( + PersonTicket4646Multiple::class, + EmployeeTicket4646Multiple::class, + ManagerTicket4646Multiple::class, + InternTicket4646Multiple::class + ); } public function testInstanceOf(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php index 62060a45a0..58c635358e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php @@ -44,9 +44,7 @@ public function testGenerateUUID(): void self::markTestSkipped('Currently restricted to MySQL platform.'); } - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(UUIDEntity::class), - ]); + $this->createSchemaForModels(UUIDEntity::class); $entity = new UUIDEntity(); $this->_em->persist($entity); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 616d12dd2b..1de95f5a7d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -341,11 +341,7 @@ public function testThrowsExceptionOnInfiniteEmbeddableNesting( ) ); - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(__NAMESPACE__ . '\\' . $embeddableClassName), - ] - ); + $this->createSchemaForModels(__NAMESPACE__ . '\\' . $embeddableClassName); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php index 483d2e587b..d008e17ef7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Exception\ORMException; use Doctrine\Tests\Models\VersionedOneToOne\FirstRelatedEntity; use Doctrine\Tests\Models\VersionedOneToOne\SecondRelatedEntity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -20,15 +19,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(FirstRelatedEntity::class), - $this->_em->getClassMetadata(SecondRelatedEntity::class), - ] - ); - } catch (ORMException $e) { - } + $this->createSchemaForModels( + FirstRelatedEntity::class, + SecondRelatedEntity::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php index 2099fd157b..a0b9fad4e7 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Utility; -use Doctrine\ORM\Exception\ORMException; use Doctrine\Tests\Models\Enums\Suit; use Doctrine\Tests\Models\Enums\TypedCardEnumCompositeId; use Doctrine\Tests\Models\Enums\TypedCardEnumId; @@ -23,15 +22,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(TypedCardEnumId::class), - $this->_em->getClassMetadata(TypedCardEnumCompositeId::class), - ] - ); - } catch (ORMException $e) { - } + $this->createSchemaForModels( + TypedCardEnumId::class, + TypedCardEnumCompositeId::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php index 716b20f738..fef687d725 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Utility; -use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\Flight; @@ -35,17 +34,12 @@ protected function setUp(): void $this->_em->getMetadataFactory() ); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(FirstRelatedEntity::class), - $this->_em->getClassMetadata(SecondRelatedEntity::class), - $this->_em->getClassMetadata(Flight::class), - $this->_em->getClassMetadata(City::class), - ] - ); - } catch (ORMException $e) { - } + $this->createSchemaForModels( + FirstRelatedEntity::class, + SecondRelatedEntity::class, + Flight::class, + City::class + ); } /** diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 22e073624c..4890793dfc 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\DefaultCacheFactory; @@ -344,16 +345,44 @@ abstract class OrmFunctionalTestCase extends OrmTestCase final protected function createSchemaForModels(string ...$models): void { try { - $this->_schemaTool->createSchema(array_map( - function (string $className): ClassMetadata { - return $this->_em->getClassMetadata($className); - }, - $models - )); + $this->_schemaTool->createSchema($this->getMetadataForModels($models)); } catch (ToolsException $e) { } } + /** + * @param class-string ...$models + * + * @return string[] + */ + final protected function getUpdateSchemaSqlForModels(string ...$models): array + { + return $this->_schemaTool->getUpdateSchemaSql($this->getMetadataForModels($models)); + } + + /** + * @param class-string ...$models + */ + final protected function getSchemaForModels(string ...$models): Schema + { + return $this->_schemaTool->getSchemaFromMetadata($this->getMetadataForModels($models)); + } + + /** + * @param class-string[] $models + * + * @return ClassMetadata[] + */ + private function getMetadataForModels(array $models): array + { + return array_map( + function (string $className): ClassMetadata { + return $this->_em->getClassMetadata($className); + }, + $models + ); + } + protected function useModelSet(string $setName): void { $this->_usedModelSets[$setName] = true; From eea53397c5a4ed8191d0d84468062f3677fca96f Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sat, 2 Jul 2022 08:19:30 +0200 Subject: [PATCH 03/13] Change parent classes *FlushEventArgs classes should extend ManagerEventArgs from doctrine/persistence to be able to use ManagerEventArgs for any persistance implementation. OnClearEventArgs should extend from OnClearEventArgs from doctrine/persistence. --- UPGRADE.md | 11 ++++++++ lib/Doctrine/ORM/Event/OnClearEventArgs.php | 24 ++++++++++++----- lib/Doctrine/ORM/Event/OnFlushEventArgs.php | 26 +++++++++++-------- lib/Doctrine/ORM/Event/PostFlushEventArgs.php | 26 +++++++++++-------- lib/Doctrine/ORM/Event/PreFlushEventArgs.php | 26 +++++++++++-------- .../ORM/Tools/DebugUnitOfWorkListener.php | 2 +- .../Tests/ORM/Functional/FlushEventTest.php | 2 +- .../ORM/Functional/PostFlushEventTest.php | 2 +- .../ORM/Functional/Ticket/DDC2790Test.php | 2 +- .../ORM/Functional/Ticket/DDC3160Test.php | 2 +- 10 files changed, 78 insertions(+), 45 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 303c37a623..031012e00c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -48,6 +48,17 @@ Calling `AbstractQuery::setFetchMode()` with anything else than `Doctrine\ORM\Mapping::FETCH_LAZY` being used. Relying on that behavior is deprecated and will result in an exception in 3.0. +## Deprecated `getEntityManager()` in `Doctrine\ORM\Event\OnClearEventArgs` and `Doctrine\ORM\Event\*FlushEventArgs` + +This method has been deprecated in: + +* `Doctrine\ORM\Event\OnClearEventArgs` +* `Doctrine\ORM\Event\OnFlushEventArgs` +* `Doctrine\ORM\Event\PostFlushEventArgs` +* `Doctrine\ORM\Event\PreFlushEventArgs` + +It will be removed in 3.0. Use `getObjectManager()` instead. + ## Prepare split of output walkers and tree walkers In 3.0, `SqlWalker` and its child classes won't implement the `TreeWalker` diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/lib/Doctrine/ORM/Event/OnClearEventArgs.php index a88c0050ae..00fffec681 100644 --- a/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -4,19 +4,19 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\OnClearEventArgs as BaseOnClearEventArgs; /** * Provides event arguments for the onClear event. * * @link www.doctrine-project.org + * + * @extends BaseOnClearEventArgs */ -class OnClearEventArgs extends EventArgs +class OnClearEventArgs extends BaseOnClearEventArgs { - /** @var EntityManagerInterface */ - private $em; - /** @var string|null */ private $entityClass; @@ -25,18 +25,28 @@ class OnClearEventArgs extends EventArgs */ public function __construct(EntityManagerInterface $em, $entityClass = null) { - $this->em = $em; + parent::__construct($em); + $this->entityClass = $entityClass; } /** * Retrieves associated EntityManager. * + * @deprecated 2.13. Use {@see getObjectManager} instead. + * * @return EntityManagerInterface */ public function getEntityManager() { - return $this->em; + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/9875', + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', + __METHOD__ + ); + + return $this->getObjectManager(); } /** diff --git a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php index a155f1a672..340719f78f 100644 --- a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php @@ -4,31 +4,35 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\ManagerEventArgs; /** * Provides event arguments for the preFlush event. * * @link www.doctrine-project.org + * + * @extends ManagerEventArgs */ -class OnFlushEventArgs extends EventArgs +class OnFlushEventArgs extends ManagerEventArgs { - /** @var EntityManagerInterface */ - private $em; - - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; - } - /** * Retrieve associated EntityManager. * + * @deprecated 2.13. Use {@see getObjectManager} instead. + * * @return EntityManagerInterface */ public function getEntityManager() { - return $this->em; + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/9875', + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', + __METHOD__ + ); + + return $this->getObjectManager(); } } diff --git a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php index 1e7c06b6a7..ae3f52a406 100644 --- a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php @@ -4,31 +4,35 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\ManagerEventArgs; /** * Provides event arguments for the postFlush event. * * @link www.doctrine-project.org + * + * @extends ManagerEventArgs */ -class PostFlushEventArgs extends EventArgs +class PostFlushEventArgs extends ManagerEventArgs { - /** @var EntityManagerInterface */ - private $em; - - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; - } - /** * Retrieves associated EntityManager. * + * @deprecated 2.13. Use {@see getObjectManager} instead. + * * @return EntityManagerInterface */ public function getEntityManager() { - return $this->em; + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/9875', + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', + __METHOD__ + ); + + return $this->getObjectManager(); } } diff --git a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php index c7d2fef488..b8bdb25538 100644 --- a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php @@ -4,29 +4,33 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\ManagerEventArgs; /** * Provides event arguments for the preFlush event. * * @link www.doctrine-project.com + * + * @extends ManagerEventArgs */ -class PreFlushEventArgs extends EventArgs +class PreFlushEventArgs extends ManagerEventArgs { - /** @var EntityManagerInterface */ - private $em; - - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; - } - /** + * @deprecated 2.13. Use {@see getObjectManager} instead. + * * @return EntityManagerInterface */ public function getEntityManager() { - return $this->em; + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/9875', + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', + __METHOD__ + ); + + return $this->getObjectManager(); } } diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index ab8b301c20..6dd36c4884 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -51,7 +51,7 @@ public function __construct($file = 'php://output', $context = '') */ public function onFlush(OnFlushEventArgs $args) { - $this->dumpIdentityMap($args->getEntityManager()); + $this->dumpIdentityMap($args->getObjectManager()); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index 608a8ae851..2e33530d12 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -78,7 +78,7 @@ public function onFlush(OnFlushEventArgs $args): void { //echo "---preFlush".PHP_EOL; - $em = $args->getEntityManager(); + $em = $args->getObjectManager(); $uow = $em->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php index 2dc289314b..cccf30e071 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -55,7 +55,7 @@ public function testListenerShouldReceiveEntityManagerThroughArgs(): void { $this->_em->persist($this->createNewValidUser()); $this->_em->flush(); - $receivedEm = $this->listener->receivedArgs->getEntityManager(); + $receivedEm = $this->listener->receivedArgs->getObjectManager(); self::assertSame($this->_em, $receivedEm); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index abf958b1e9..42be715dea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -67,7 +67,7 @@ class OnFlushListener */ public function onFlush(OnFlushEventArgs $args): void { - $em = $args->getEntityManager(); + $em = $args->getObjectManager(); $uow = $em->getUnitOfWork(); $deletions = $uow->getScheduledEntityDeletions(); $updates = $uow->getScheduledEntityUpdates(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index 91a57bedd9..adaade063a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -56,7 +56,7 @@ class DDC3160OnFlushListener public function onFlush(OnFlushEventArgs $args): void { - $em = $args->getEntityManager(); + $em = $args->getObjectManager(); $uow = $em->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { From 79447cbb1872346bbebfc892ea3d023007690100 Mon Sep 17 00:00:00 2001 From: Alex Popov Date: Sun, 3 Jul 2022 13:25:34 +0400 Subject: [PATCH 04/13] ObjectHydrator: defer initialization of potentially empty collections If ObjectHydrator faces an empty row to an uninitialized collection, it initializes it, to prevent it from querying again (DDC-1526). However, if that row is the first but not the only in the collection, the next rows will be ignored, as the collection will be considered "existing", and "existing" collections are only replaced if REFRESH hint is present. To prevent it, we defer initialization to the end of the hydration. Fixes GH-9807 --- .../ORM/Internal/Hydration/ObjectHydrator.php | 31 +++-- .../ORM/Functional/Ticket/GH9807Test.php | 129 ++++++++++++++++++ 2 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 4f21a578a9..20865f1081 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -44,6 +44,9 @@ class ObjectHydrator extends AbstractHydrator /** @var mixed[] */ private $initializedCollections = []; + /** @var array */ + private $uninitializedCollections = []; + /** @var mixed[] */ private $existingCollections = []; @@ -112,10 +115,11 @@ protected function cleanup() parent::cleanup(); - $this->identifierMap = - $this->initializedCollections = - $this->existingCollections = - $this->resultPointers = []; + $this->identifierMap = + $this->initializedCollections = + $this->uninitializedCollections = + $this->existingCollections = + $this->resultPointers = []; if ($eagerLoad) { $this->_uow->triggerEagerLoads(); @@ -126,10 +130,11 @@ protected function cleanup() protected function cleanupAfterRowIteration(): void { - $this->identifierMap = - $this->initializedCollections = - $this->existingCollections = - $this->resultPointers = []; + $this->identifierMap = + $this->initializedCollections = + $this->uninitializedCollections = + $this->existingCollections = + $this->resultPointers = []; } /** @@ -148,6 +153,12 @@ protected function hydrateAllData() $coll->takeSnapshot(); } + foreach ($this->uninitializedCollections as $coll) { + if (! $coll->isInitialized()) { + $coll->setInitialized(true); + } + } + return $result; } @@ -411,8 +422,8 @@ protected function hydrateRowData(array $row, array &$result) } } elseif (! $reflFieldValue) { $this->initRelatedCollection($parentObject, $parentClass, $relationField, $parentAlias); - } elseif ($reflFieldValue instanceof PersistentCollection && $reflFieldValue->isInitialized() === false) { - $reflFieldValue->setInitialized(true); + } elseif ($reflFieldValue instanceof PersistentCollection && $reflFieldValue->isInitialized() === false && ! isset($this->uninitializedCollections[$oid . $relationField])) { + $this->uninitializedCollections[$oid . $relationField] = $reflFieldValue; } } else { // PATH B: Single-valued association diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php new file mode 100644 index 0000000000..c7cb744d1c --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php @@ -0,0 +1,129 @@ +createSchemaForModels(GH9807Main::class, GH9807Join::class); + } + + public function testHydrateJoinedCollectionWithFirstNullishRow(): void + { + $rsm = new ResultSetMapping(); + $rsm->addEntityResult(GH9807Main::class, 'm'); + $rsm->addJoinedEntityResult(GH9807Join::class, 'j', 'm', 'joins'); + + $rsm->addFieldResult('m', 'id_0', 'id'); + $rsm->addFieldResult('j', 'id_1', 'id'); + $rsm->addFieldResult('j', 'value_2', 'value'); + + $hydrator = new ObjectHydrator($this->_em); + + $uow = $this->_em->getUnitOfWork(); + + $uow->createEntity( + GH9807Main::class, + ['id' => 1] + ); + + $resultSet = [ + [ + 'id_0' => 1, + 'id_1' => null, + 'value_2' => null, + ], + [ + 'id_0' => 1, + 'id_1' => 1, + 'value_2' => '2', + ], + [ + 'id_0' => 1, + 'id_1' => 2, + 'value_2' => '2', + ], + ]; + + $stmt = ArrayResultFactory::createFromArray($resultSet); + + /** @var GH9807Main[] $result */ + $result = $hydrator->hydrateAll($stmt, $rsm); + + self::assertInstanceOf(GH9807Main::class, $result[0]); + self::assertCount(2, $result[0]->getJoins()); + } +} + +/** + * @Entity + */ +class GH9807Main +{ + /** + * @var int + * @Column(type="integer") + * @Id + * @GeneratedValue + */ + private $id; + + /** + * @ORM\ManyToMany(targetEntity="GH9807Join", inversedBy="starts") + * + * @var Collection + */ + private $joins; + + /** + * @return Collection + */ + public function getJoins(): Collection + { + return $this->joins; + } +} + +/** + * @Entity + */ +class GH9807Join +{ + /** + * @var int + * @Column(type="integer") + * @Id + * @GeneratedValue + */ + private $id; + + /** + * @ORM\ManyToMany(targetEntity="GH9807Main", mappedBy="bases") + * + * @var Collection + */ + private $mains; + + /** + * @ORM\Column(type="string", nullable=false) + * + * @var string + */ + private $value; +} From 306b5f9812081b5fb7c10411c43e47bf5631d925 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 6 Jul 2022 14:06:42 +0200 Subject: [PATCH 05/13] Fix typo in AbstractQuery --- lib/Doctrine/ORM/AbstractQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 6a6c3bbe98..bf49d59fac 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -197,7 +197,7 @@ public function setCacheable($cacheable) } /** - * @return bool TRUE if the query results are enable for second level cache, FALSE otherwise. + * @return bool TRUE if the query results are enabled for second level cache, FALSE otherwise. */ public function isCacheable() { From 291765e879e54fc569fd65e6262d8f5e4c00f04f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 8 Jul 2022 13:53:03 +0200 Subject: [PATCH 06/13] PHPStan 1.8.0 (#9887) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5109430840..de0f5e41ea 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "doctrine/annotations": "^1.13", "doctrine/coding-standard": "^9.0", "phpbench/phpbench": "^0.16.10 || ^1.0", - "phpstan/phpstan": "~1.4.10 || 1.7.15", + "phpstan/phpstan": "~1.4.10 || 1.8.0", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.1", From baf6a394a1ea3cd5c6979ae8ad5ae9a4b6852248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 10 Jul 2022 11:12:28 +0200 Subject: [PATCH 07/13] Test invalid mapping file with boolean model SerializationModel has a field with type array, and another with type object. Both types are deprecated. --- tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php | 6 +++--- tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php | 6 +++--- ...l => Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml} | 4 +--- ...l => Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml} | 6 ++---- 4 files changed, 9 insertions(+), 13 deletions(-) rename tests/Doctrine/Tests/ORM/Mapping/xml/{Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml => Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml} (80%) rename tests/Doctrine/Tests/ORM/Mapping/yaml/{Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml => Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml} (68%) diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 96e0deaf63..29320e9e41 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -15,7 +15,7 @@ use Doctrine\Tests\Models\DDC3293\DDC3293User; use Doctrine\Tests\Models\DDC3293\DDC3293UserPrefixed; use Doctrine\Tests\Models\DDC889\DDC889Class; -use Doctrine\Tests\Models\Generic\SerializationModel; +use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\Models\GH7141\GH7141Article; use Doctrine\Tests\Models\GH7316\GH7316Article; use Doctrine\Tests\Models\ValueObjects\Name; @@ -155,8 +155,8 @@ public function testEmbeddedMapping(): void public function testInvalidMappingFileException(): void { $this->expectException('Doctrine\Persistence\Mapping\MappingException'); - $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml\' for class \'Doctrine\Tests\Models\Generic\SerializationModel\'.'); - $this->createClassMetadata(SerializationModel::class); + $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml\' for class \'Doctrine\Tests\Models\Generic\BooleanModel\'.'); + $this->createClassMetadata(BooleanModel::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index 77db11396a..c1f1365c54 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -11,7 +11,7 @@ use Doctrine\Tests\Models\DDC3711\DDC3711EntityA; use Doctrine\Tests\Models\DirectoryTree\Directory; use Doctrine\Tests\Models\DirectoryTree\File; -use Doctrine\Tests\Models\Generic\SerializationModel; +use Doctrine\Tests\Models\Generic\BooleanModel; use Symfony\Component\Yaml\Yaml; use function class_exists; @@ -59,8 +59,8 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver(): void public function testInvalidMappingFileException(): void { $this->expectException('Doctrine\Persistence\Mapping\MappingException'); - $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml\' for class \'Doctrine\Tests\Models\Generic\SerializationModel\'.'); - $this->createClassMetadata(SerializationModel::class); + $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml\' for class \'Doctrine\Tests\Models\Generic\BooleanModel\'.'); + $this->createClassMetadata(BooleanModel::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml similarity index 80% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml rename to tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml index 6e42bce75a..1594b1e01d 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml @@ -9,9 +9,7 @@ - - - + diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml similarity index 68% rename from tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml rename to tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml index a20b572593..5b1ec64b87 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml @@ -7,7 +7,5 @@ generator: strategy: AUTO fields: - array: - type: array - object: - type: object + booleanField: + type: boolean From d6dcfbd6f7577e550c0e62c78674e277511efd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 10 Jul 2022 11:20:12 +0200 Subject: [PATCH 08/13] Use ::class notation --- tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php | 3 ++- tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 29320e9e41..fba70b6451 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\Models\DDC117\DDC117Translation; use Doctrine\Tests\Models\DDC3293\DDC3293User; @@ -154,7 +155,7 @@ public function testEmbeddedMapping(): void */ public function testInvalidMappingFileException(): void { - $this->expectException('Doctrine\Persistence\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml\' for class \'Doctrine\Tests\Models\Generic\BooleanModel\'.'); $this->createClassMetadata(BooleanModel::class); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index c1f1365c54..a6a81f90f3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Driver\YamlDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Tests\Models\DDC3711\DDC3711EntityA; use Doctrine\Tests\Models\DirectoryTree\Directory; use Doctrine\Tests\Models\DirectoryTree\File; @@ -58,7 +59,7 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver(): void */ public function testInvalidMappingFileException(): void { - $this->expectException('Doctrine\Persistence\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml\' for class \'Doctrine\Tests\Models\Generic\BooleanModel\'.'); $this->createClassMetadata(BooleanModel::class); } From 7ed0db0621387cea68bd776dc74780285bb641c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 10 Jul 2022 11:20:24 +0200 Subject: [PATCH 09/13] Document what we test in test method name --- tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php | 2 +- tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index fba70b6451..df94d52c98 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -153,7 +153,7 @@ public function testEmbeddedMapping(): void /** * @group DDC-1468 */ - public function testInvalidMappingFileException(): void + public function testItMentionsFilenameAndEntityNameOnInvalidMapping(): void { $this->expectException(MappingException::class); $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml\' for class \'Doctrine\Tests\Models\Generic\BooleanModel\'.'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index a6a81f90f3..3342cdaf70 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -57,7 +57,7 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver(): void /** * @group DDC-1468 */ - public function testInvalidMappingFileException(): void + public function testItMentionsFilenameAndEntityNameOnInvalidMapping(): void { $this->expectException(MappingException::class); $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml\' for class \'Doctrine\Tests\Models\Generic\BooleanModel\'.'); From 00989d667174a5b77e8b8735daaac6e595c14286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 10 Jul 2022 12:23:05 +0200 Subject: [PATCH 10/13] Remove SerializationModel from generic model set It contains fields with deprecated types. --- tests/Doctrine/Tests/ORM/Functional/TypeTest.php | 4 ++++ tests/Doctrine/Tests/OrmFunctionalTestCase.php | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index c4fc6b4465..c52fe61b34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -74,6 +74,8 @@ public function testArray(): void $serialize->array['foo'] = 'bar'; $serialize->array['bar'] = 'baz'; + $this->createSchemaForModels(SerializationModel::class); + static::$sharedConn->executeStatement('DELETE FROM serialize_model'); $this->_em->persist($serialize); $this->_em->flush(); $this->_em->clear(); @@ -89,6 +91,8 @@ public function testObject(): void $serialize = new SerializationModel(); $serialize->object = new stdClass(); + $this->createSchemaForModels(SerializationModel::class); + static::$sharedConn->executeStatement('DELETE FROM serialize_model'); $this->_em->persist($serialize); $this->_em->flush(); $this->_em->clear(); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 4890793dfc..3c49f23e2c 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -154,7 +154,6 @@ abstract class OrmFunctionalTestCase extends OrmTestCase Models\Generic\BooleanModel::class, Models\Generic\DateTimeModel::class, Models\Generic\DecimalModel::class, - Models\Generic\SerializationModel::class, ], 'routing' => [ Models\Routing\RoutingLeg::class, @@ -452,7 +451,6 @@ protected function tearDown(): void $conn->executeStatement('DELETE FROM boolean_model'); $conn->executeStatement('DELETE FROM date_time_model'); $conn->executeStatement('DELETE FROM decimal_model'); - $conn->executeStatement('DELETE FROM serialize_model'); } if (isset($this->_usedModelSets['routing'])) { From 68dc5fe9019802981e934960726c43f54debcb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 7 Jul 2022 17:44:21 +0200 Subject: [PATCH 11/13] Rely on platform options Custom schema options have been removed in doctrine/dbal 4 --- lib/Doctrine/ORM/Tools/SchemaTool.php | 4 ++-- .../Tests/ORM/Tools/SchemaToolTest.php | 24 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 8d26133dea..f357e85619 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -786,8 +786,8 @@ private function gatherColumnOptions(array $mapping): array return []; } - $options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS)); - $options['customSchemaOptions'] = array_diff_key($mappingOptions, $options); + $options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS)); + $options['platformOptions'] = array_diff_key($mappingOptions, $options); return $options; } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index fde54c8689..76c9a2cde5 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -77,7 +77,7 @@ public function testAnnotationOptionsAttribute(): void ); $table = $schema->getTable('TestEntityWithAnnotationOptionsAttribute'); - foreach ([$table->getOptions(), $table->getColumn('test')->getCustomSchemaOptions()] as $options) { + foreach ([$table->getOptions(), $table->getColumn('test')->getPlatformOptions()] as $options) { self::assertArrayHasKey('foo', $options); self::assertSame('bar', $options['foo']); self::assertArrayHasKey('baz', $options); @@ -136,14 +136,14 @@ public function testPassColumnOptionsToJoinColumn(): void ); self::assertEquals( - $tableCategory->getColumn('id')->getCustomSchemaOptions(), - $tableBoard->getColumn('category_id')->getCustomSchemaOptions(), + $tableCategory->getColumn('id')->getPlatformOptions(), + $tableBoard->getColumn('category_id')->getPlatformOptions(), 'Foreign key/join column should have the same custom options as the referenced column' ); self::assertEquals( ['collation' => 'latin1_bin', 'foo' => 'bar'], - $tableBoard->getColumn('category_id')->getCustomSchemaOptions() + $tableBoard->getColumn('category_id')->getPlatformOptions() ); } @@ -177,17 +177,15 @@ public function testPostGenerateEvents(): void self::assertTrue($listener->schemaCalled); } - public function testNullDefaultNotAddedToCustomSchemaOptions(): void + public function testNullDefaultNotAddedToPlatformOptions(): void { $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); - $customSchemaOptions = $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(NullDefaultColumn::class)]) + self::assertSame([], $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(NullDefaultColumn::class)]) ->getTable('NullDefaultColumn') ->getColumn('nullDefault') - ->getCustomSchemaOptions(); - - self::assertSame([], $customSchemaOptions); + ->getPlatformOptions()); } /** @@ -198,13 +196,13 @@ public function testEnumTypeAddedToCustomSchemaOptions(): void $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); - $customSchemaOptions = $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(Card::class)]) + $platformOptions = $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(Card::class)]) ->getTable('Card') ->getColumn('suit') - ->getCustomSchemaOptions(); + ->getPlatformOptions(); - self::assertArrayHasKey('enumType', $customSchemaOptions); - self::assertSame(Suit::class, $customSchemaOptions['enumType']); + self::assertArrayHasKey('enumType', $platformOptions); + self::assertSame(Suit::class, $platformOptions['enumType']); } /** From 1fa1e7072b59c1a325f00ce58c8e07670d8b8e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 12 Jul 2022 20:02:46 +0200 Subject: [PATCH 12/13] Address removal/deprecation of ArrayType/ObjectType --- psalm.xml | 5 +++++ tests/Doctrine/Tests/ORM/Functional/TypeTest.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/psalm.xml b/psalm.xml index 0e34c912cf..84099bfb53 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,6 +17,11 @@ + + + + + diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index 18877e8cec..bbaeb97007 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -6,6 +6,8 @@ use DateTime; use DateTimeZone; +use Doctrine\DBAL\Types\ArrayType; +use Doctrine\DBAL\Types\ObjectType; use Doctrine\DBAL\Types\Types; use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\Models\Generic\DateTimeModel; @@ -14,6 +16,8 @@ use Doctrine\Tests\OrmFunctionalTestCase; use stdClass; +use function class_exists; + class TypeTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -70,6 +74,10 @@ public function testBoolean(): void public function testArray(): void { + if (! class_exists(ArrayType::class)) { + self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); + } + $serialize = new SerializationModel(); $serialize->array['foo'] = 'bar'; $serialize->array['bar'] = 'baz'; @@ -88,6 +96,10 @@ public function testArray(): void public function testObject(): void { + if (! class_exists(ObjectType::class)) { + self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); + } + $serialize = new SerializationModel(); $serialize->object = new stdClass(); From 1ac9d5233279de62c25f5b08706745b985bf79b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 12 Jul 2022 20:14:15 +0200 Subject: [PATCH 13/13] Ignore errors caused by nullable assets filter --- phpstan-dbal4.neon | 4 ++++ psalm.xml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index b8c63ba0d5..fa8291b861 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -18,3 +18,7 @@ parameters: - message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php + + - + message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' + path: lib/Doctrine/ORM/Tools/SchemaTool.php diff --git a/psalm.xml b/psalm.xml index 84099bfb53..3f3b111cdb 100644 --- a/psalm.xml +++ b/psalm.xml @@ -116,6 +116,12 @@ + + + + + +