diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 90e3eb35e5f..3266e088a35 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Proxy\Proxy; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function count; use function get_class; @@ -30,19 +28,13 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - $schemaTool = new SchemaTool($this->_em); - try { - $schemaTool->createSchema( - [ - $this->_em->getClassMetadata(Train::class), - $this->_em->getClassMetadata(TrainDriver::class), - $this->_em->getClassMetadata(TrainOwner::class), - $this->_em->getClassMetadata(Waggon::class), - $this->_em->getClassMetadata(TrainOrder::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + Train::class, + TrainDriver::class, + TrainOwner::class, + Waggon::class, + TrainOrder::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php index 999b6aeae9b..593ddbb33ea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -14,22 +14,16 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class PersistentCollectionTest extends OrmFunctionalTestCase { protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(PersistentCollectionHolder::class), - $this->_em->getClassMetadata(PersistentCollectionContent::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + PersistentCollectionHolder::class, + PersistentCollectionContent::class + ); PersistentObject::setObjectManager($this->_em); } diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php index 37063374cef..83a0b7259c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * Test that Doctrine ORM correctly works with the ObjectManagerAware and PersistentObject @@ -25,14 +24,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(PersistentEntity::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(PersistentEntity::class); PersistentObject::setObjectManager($this->_em); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php index e7bc792a6d9..74ea162fbce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php @@ -13,7 +13,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser as CmsUserProxy; -use Exception; use function assert; @@ -34,20 +33,15 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(CmsUser::class), - $this->_em->getClassMetadata(CmsTag::class), - $this->_em->getClassMetadata(CmsPhonenumber::class), - $this->_em->getClassMetadata(CmsArticle::class), - $this->_em->getClassMetadata(CmsAddress::class), - $this->_em->getClassMetadata(CmsEmail::class), - $this->_em->getClassMetadata(CmsGroup::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + CmsUser::class, + CmsTag::class, + CmsPhonenumber::class, + CmsArticle::class, + CmsAddress::class, + CmsEmail::class, + CmsGroup::class + ); $this->user = new CmsUser(); $this->user->username = 'ocramius'; diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 8dd8b91846e..13d9879ff0d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function get_class; @@ -25,14 +24,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(ReadOnlyEntity::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(ReadOnlyEntity::class); } public function testReadOnlyEntityNeverChangeTracked(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index 5171775c9a1..ace932b7439 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\SequenceGenerator; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * Description of SequenceGeneratorTest @@ -25,14 +24,7 @@ protected function setUp(): void self::markTestSkipped('Only working for Databases that support sequences.'); } - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(SequenceEntity::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(SequenceEntity::class); } public function testHighAllocationSizeSequence(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index 351fba5400b..a33cac1d5ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1113 @@ -25,17 +24,12 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1113Engine::class), - $this->_em->getClassMetadata(DDC1113Vehicle::class), - $this->_em->getClassMetadata(DDC1113Car::class), - $this->_em->getClassMetadata(DDC1113Bus::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC1113Engine::class, + DDC1113Vehicle::class, + DDC1113Car::class, + DDC1113Bus::class + ); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index 5d5df56df4d..0b6916d908b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -12,23 +12,17 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC1209Test extends OrmFunctionalTestCase { protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1209One::class), - $this->_em->getClassMetadata(DDC1209Two::class), - $this->_em->getClassMetadata(DDC1209Three::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC1209One::class, + DDC1209Two::class, + DDC1209Three::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index 4c2e02601cc..23abd4abf9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1228 @@ -21,15 +20,7 @@ class DDC1228Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1228User::class), - $this->_em->getClassMetadata(DDC1228Profile::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC1228User::class, DDC1228Profile::class); } public function testOneToOnePersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index 81f3d9c1009..7b97a1963b1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1238 @@ -19,14 +18,7 @@ class DDC1238Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1238User::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC1238User::class); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index 38764356e36..b4c65885065 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-1335 @@ -24,16 +23,8 @@ class DDC1335Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1335User::class), - $this->_em->getClassMetadata(DDC1335Phone::class), - ] - ); - $this->loadFixture(); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC1335User::class, DDC1335Phone::class); + $this->loadFixture(); } public function testDql(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index 7e668d942bf..3f59313c25a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function get_class; @@ -25,15 +24,10 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1461TwitterAccount::class), - $this->_em->getClassMetadata(DDC1461User::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC1461TwitterAccount::class, + DDC1461User::class + ); } public function testChangeDetectionDeferredExplicit(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index d483a974a09..bb423ded1b4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -16,7 +16,6 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\PostLoad; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function get_class; use function get_debug_type; @@ -32,16 +31,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1655Foo::class), - $this->_em->getClassMetadata(DDC1655Bar::class), - $this->_em->getClassMetadata(DDC1655Baz::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC1655Foo::class, + DDC1655Bar::class, + DDC1655Baz::class + ); } public function testPostLoadOneToManyInheritance(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index e6c3d0a296e..59f7e482f65 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\PrePersist; use Doctrine\ORM\Mapping\PreUpdate; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function assert; use function get_class; @@ -24,14 +23,7 @@ class DDC2895Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2895::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC2895::class); } public function testPostLoadOneToManyInheritance(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index 851c3771627..d5e37e66881 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -18,7 +18,6 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC3785Test extends OrmFunctionalTestCase { @@ -28,16 +27,11 @@ protected function setUp(): void Type::addType('ddc3785_asset_id', DDC3785AssetIdType::class); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC3785Asset::class), - $this->_em->getClassMetadata(DDC3785AssetId::class), - $this->_em->getClassMetadata(DDC3785Attribute::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC3785Asset::class, + DDC3785AssetId::class, + DDC3785Attribute::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php index 439b8388a03..80f012401c5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function serialize; use function unserialize; @@ -20,14 +19,7 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC381Entity::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC381Entity::class); } public function testCallUnserializedProxyMethods(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index be563e2fbfd..769bcfc701d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function get_class; @@ -26,16 +25,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC522Customer::class), - $this->_em->getClassMetadata(DDC522Cart::class), - $this->_em->getClassMetadata(DDC522ForeignKeyTest::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC522Customer::class, + DDC522Cart::class, + DDC522ForeignKeyTest::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index ea1eed00bc0..75595e3d929 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; /** * @group DDC-618 @@ -24,34 +23,26 @@ class DDC618Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC618Author::class), - $this->_em->getClassMetadata(DDC618Book::class), - ] - ); - - // Create author 10/Joe with two books 22/JoeA and 20/JoeB - $author = new DDC618Author(); - $author->id = 10; - $author->name = 'Joe'; - $this->_em->persist($author); - - // Create author 11/Alice with two books 21/AliceA and 23/AliceB - $author = new DDC618Author(); - $author->id = 11; - $author->name = 'Alice'; - $author->addBook('In Wonderland'); - $author->addBook('Reloaded'); - $author->addBook('Test'); - - $this->_em->persist($author); - - $this->_em->flush(); - $this->_em->clear(); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC618Author::class, DDC618Book::class); + + // Create author 10/Joe with two books 22/JoeA and 20/JoeB + $author = new DDC618Author(); + $author->id = 10; + $author->name = 'Joe'; + $this->_em->persist($author); + + // Create author 11/Alice with two books 21/AliceA and 23/AliceB + $author = new DDC618Author(); + $author->id = 11; + $author->name = 'Alice'; + $author->addBook('In Wonderland'); + $author->addBook('Reloaded'); + $author->addBook('Test'); + + $this->_em->persist($author); + + $this->_em->flush(); + $this->_em->clear(); } public function testIndexByHydrateObject(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index 78750bcd71d..12f04591656 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -11,22 +11,16 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC633Test extends OrmFunctionalTestCase { protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC633Patient::class), - $this->_em->getClassMetadata(DDC633Appointment::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC633Patient::class, + DDC633Appointment::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index 30e5920a60e..289022d9f18 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function array_keys; use function get_class; @@ -19,14 +18,7 @@ class DDC656Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC656Entity::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC656Entity::class); } public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php index 6b8ebb44b54..f53b69fa77f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function strtolower; @@ -23,15 +22,7 @@ class DDC698Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC698Role::class), - $this->_em->getClassMetadata(DDC698Privilege::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC698Role::class, DDC698Privilege::class); } public function testTicket(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php index 3754508b175..5cd99e83794 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\PersistentCollection; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function count; @@ -24,16 +22,7 @@ protected function setUp(): void { parent::setUp(); - try { - $schemaTool = new SchemaTool($this->_em); - $schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC729A::class), - $this->_em->getClassMetadata(DDC729B::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC729A::class, DDC729B::class); } public function testMergeManyToMany(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index 02ffb33da8c..ff1f23e176a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -13,22 +13,13 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC735Test extends OrmFunctionalTestCase { protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC735Product::class), - $this->_em->getClassMetadata(DDC735Review::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC735Product::class, DDC735Review::class); } public function testRemoveElementAppliesOrphanRemoval(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php index b331cd4d0f3..5fc3f049240 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php @@ -16,7 +16,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\PersistentCollection; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function class_exists; use function mkdir; @@ -43,15 +42,7 @@ protected function setUp(): void // using a Filesystemcache to ensure that the cached data is serialized $this->_em->getMetadataFactory()->setCacheDriver(new FilesystemCache($testDir)); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC742User::class), - $this->_em->getClassMetadata(DDC742Comment::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC742User::class, DDC742Comment::class); // make sure classes will be deserialized from caches $this->_em->getMetadataFactory()->setMetadataFor(DDC742User::class, null); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index e3946ae11c4..dfda86d183c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -15,7 +15,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC832Test extends OrmFunctionalTestCase { @@ -27,16 +26,11 @@ protected function setUp(): void self::markTestSkipped('Doesnt run on Oracle.'); } - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC832JoinedIndex::class), - $this->_em->getClassMetadata(DDC832JoinedTreeIndex::class), - $this->_em->getClassMetadata(DDC832Like::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC832JoinedIndex::class, + DDC832JoinedTreeIndex::class, + DDC832Like::class + ); } public function tearDown(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 5105cf2bdbc..906e60ed3a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -17,7 +17,6 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC881Test extends OrmFunctionalTestCase { @@ -25,16 +24,11 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC881User::class), - $this->_em->getClassMetadata(DDC881Phonenumber::class), - $this->_em->getClassMetadata(DDC881Phonecall::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC881User::class, + DDC881PhoneNumber::class, + DDC881PhoneCall::class + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index beba062b85a..fbf86a3d782 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -12,22 +12,13 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; class DDC960Test extends OrmFunctionalTestCase { protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC960Root::class), - $this->_em->getClassMetadata(DDC960Child::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels(DDC960Root::class, DDC960Child::class); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index 053dda766dc..47d12315ddd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -18,7 +18,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function get_class; @@ -30,16 +29,11 @@ class DDC992Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC992Role::class), - $this->_em->getClassMetadata(DDC992Parent::class), - $this->_em->getClassMetadata(DDC992Child::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC992Role::class, + DDC992Parent::class, + DDC992Child::class + ); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index e185853c97f..616d12dd2b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -21,7 +21,6 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\Persistence\Reflection\RuntimePublicReflectionProperty; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function class_exists; use function sprintf; @@ -35,19 +34,14 @@ protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC93Person::class), - $this->_em->getClassMetadata(DDC93Address::class), - $this->_em->getClassMetadata(DDC93Vehicle::class), - $this->_em->getClassMetadata(DDC93Car::class), - $this->_em->getClassMetadata(DDC3027Animal::class), - $this->_em->getClassMetadata(DDC3027Dog::class), - ] - ); - } catch (Exception $e) { - } + $this->createSchemaForModels( + DDC93Person::class, + DDC93Address::class, + DDC93Vehicle::class, + DDC93Car::class, + DDC3027Animal::class, + DDC3027Dog::class + ); } public function testMetadataHasReflectionEmbeddablesAccessible(): void diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index fbaa297eb65..4c9f3142fa6 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\ORMException; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Tools\DebugUnitOfWorkListener; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\Mapping\Driver\MappingDriver; @@ -337,6 +338,37 @@ abstract class OrmFunctionalTestCase extends OrmTestCase ], ]; + /** @var list */ + private $modelsToTearDown = []; + + /** + * @param list $models + */ + final protected function createSchemaForModels(string ...$models): void + { + $this->modelsToTearDown = $models; + $this->_schemaTool->createSchema(array_map( + function (string $className): ClassMetadata { + return $this->_em->getClassMetadata($className); + }, + $models + )); + } + + /** + * @after + */ + public function tearDownModels(): void + { + $this->_schemaTool->dropSchema(array_map( + function (string $className): ClassMetadata { + return $this->_em->getClassMetadata($className); + }, + $this->modelsToTearDown + )); + $this->modelsToTearDown = []; + } + protected function useModelSet(string $setName): void { $this->_usedModelSets[$setName] = true;