From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Thu, 20 Feb 2025 12:15:49 +0100
Subject: Modernize PHPUnit syntax

---
 tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php                 | 2 ++
 tests/Tests/ORM/Cache/DefaultCacheTest.php                        | 2 ++
 tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php               | 2 ++
 tests/Tests/ORM/Cache/DefaultQueryCacheTest.php                   | 2 ++
 .../NonStrictReadWriteCachedCollectionPersisterTest.php           | 2 ++
 .../Collection/ReadOnlyCachedCollectionPersisterTest.php          | 2 ++
 .../Collection/ReadWriteCachedCollectionPersisterTest.php         | 2 ++
 .../Entity/NonStrictReadWriteCachedEntityPersisterTest.php        | 2 ++
 .../Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php  | 2 ++
 .../Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php | 2 ++
 tests/Tests/ORM/EntityManagerTest.php                             | 2 ++
 tests/Tests/ORM/Functional/EntityRepositoryTest.php               | 4 ++--
 tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php            | 8 ++++----
 tests/Tests/ORM/Functional/QueryCacheTest.php                     | 6 ++++--
 tests/Tests/ORM/Functional/SingleTableInheritanceTest.php         | 6 +++---
 tests/Tests/ORM/Functional/Ticket/DDC117Test.php                  | 8 ++++----
 tests/Tests/ORM/Functional/Ticket/DDC3042Test.php                 | 2 ++
 tests/Tests/ORM/Functional/Ticket/DDC3170Test.php                 | 4 ++--
 tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php         | 3 ++-
 tests/Tests/ORM/Functional/Ticket/GH10387Test.php                 | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH10450Test.php                 | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH10454Test.php                 | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH10473Test.php                 | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php         | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php         | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH8061Test.php                  | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php | 2 ++
 tests/Tests/ORM/Functional/Ticket/GH8914Test.php                  | 2 ++
 tests/Tests/ORM/Hydration/AbstractHydratorTest.php                | 2 ++
 tests/Tests/ORM/Hydration/ArrayHydratorTest.php                   | 2 ++
 tests/Tests/ORM/Hydration/CustomHydratorTest.php                  | 2 ++
 tests/Tests/ORM/Hydration/ObjectHydratorTest.php                  | 2 ++
 tests/Tests/ORM/Hydration/ResultSetMappingTest.php                | 2 ++
 tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php            | 2 ++
 tests/Tests/ORM/Hydration/ScalarHydratorTest.php                  | 2 ++
 tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php            | 2 ++
 tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php            | 2 ++
 tests/Tests/ORM/Id/AssignedGeneratorTest.php                      | 2 ++
 tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php                 | 3 +++
 tests/Tests/ORM/Mapping/AttributeDriverTest.php                   | 2 ++
 tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php           | 2 ++
 tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php            | 2 ++
 tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php              | 2 ++
 tests/Tests/ORM/Mapping/QuoteStrategyTest.php                     | 2 ++
 tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php            | 2 ++
 tests/Tests/ORM/Mapping/XmlMappingDriverTest.php                  | 2 ++
 .../BasicEntityPersisterCompositeTypeParametersTest.php           | 2 ++
 .../ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php   | 2 ++
 .../Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php | 2 ++
 tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php            | 2 ++
 tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php               | 2 ++
 tests/Tests/ORM/Query/CustomTreeWalkersTest.php                   | 2 ++
 tests/Tests/ORM/Query/DeleteSqlGenerationTest.php                 | 2 ++
 tests/Tests/ORM/Query/ExprTest.php                                | 2 ++
 tests/Tests/ORM/Query/FilterCollectionTest.php                    | 6 ++++--
 tests/Tests/ORM/Query/LanguageRecognitionTest.php                 | 2 ++
 tests/Tests/ORM/Query/NativeQueryTest.php                         | 2 ++
 tests/Tests/ORM/Query/ParserResultTest.php                        | 2 ++
 tests/Tests/ORM/Query/ParserTest.php                              | 2 ++
 tests/Tests/ORM/Query/QueryTest.php                               | 3 +++
 tests/Tests/ORM/Query/SelectSqlGenerationTest.php                 | 2 ++
 tests/Tests/ORM/Query/SqlWalkerTest.php                           | 2 ++
 tests/Tests/ORM/Query/UpdateSqlGenerationTest.php                 | 2 ++
 tests/Tests/ORM/QueryBuilderTest.php                              | 2 ++
 tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php       | 2 +-
 tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php       | 2 ++
 tests/Tests/ORM/Tools/Console/MetadataFilterTest.php              | 2 ++
 tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php        | 2 ++
 tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php              | 2 ++
 .../Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php  | 2 ++
 tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php      | 2 ++
 tests/Tests/ORM/Tools/Pagination/PaginatorTest.php                | 2 ++
 tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php           | 2 ++
 tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php            | 2 ++
 tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php         | 2 ++
 tests/Tests/ORM/Tools/SchemaToolTest.php                          | 2 ++
 tests/Tests/ORM/Tools/SchemaValidatorTest.php                     | 2 ++
 tests/Tests/ORM/UnitOfWorkTest.php                                | 2 ++
 78 files changed, 166 insertions(+), 21 deletions(-)

diff --git a/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php
index bdb3d2a..126d8e5 100644
--- a/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php
+++ b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php
@@ -29,10 +29,12 @@ use Doctrine\Tests\OrmTestCase;
 use InvalidArgumentException;
 use LogicException;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use PHPUnit\Framework\MockObject\MockObject;
 use Psr\Cache\CacheItemPoolInterface;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class DefaultCacheFactoryTest extends OrmTestCase
 {
     private CacheFactory&MockObject $factory;
diff --git a/tests/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Tests/ORM/Cache/DefaultCacheTest.php
index cd30af1..1ead887 100644
--- a/tests/Tests/ORM/Cache/DefaultCacheTest.php
+++ b/tests/Tests/ORM/Cache/DefaultCacheTest.php
@@ -18,12 +18,14 @@ use Doctrine\Tests\Models\Cache\State;
 use Doctrine\Tests\Models\CMS\CmsUser;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionMethod;
 use ReflectionProperty;
 
 use function array_merge;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class DefaultCacheTest extends OrmTestCase
 {
     private DefaultCache $cache;
diff --git a/tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php
index e3271be..4a47379 100644
--- a/tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php
+++ b/tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php
@@ -16,8 +16,10 @@ use Doctrine\Tests\Models\Cache\Country;
 use Doctrine\Tests\Models\Cache\State;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class DefaultEntityHydratorTest extends OrmTestCase
 {
     private DefaultEntityHydrator $structure;
diff --git a/tests/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Tests/ORM/Cache/DefaultQueryCacheTest.php
index 2edc63a..24a7796 100644
--- a/tests/Tests/ORM/Cache/DefaultQueryCacheTest.php
+++ b/tests/Tests/ORM/Cache/DefaultQueryCacheTest.php
@@ -27,12 +27,14 @@ use Doctrine\Tests\Models\Cache\State;
 use Doctrine\Tests\Models\Generic\BooleanModel;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionMethod;
 
 use function microtime;
 use function sprintf;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class DefaultQueryCacheTest extends OrmTestCase
 {
     private DefaultQueryCache $queryCache;
diff --git a/tests/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php
index 4b79d02..493d3ef 100644
--- a/tests/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php
+++ b/tests/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php
@@ -11,8 +11,10 @@ use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\ORM\Mapping\AssociationMapping;
 use Doctrine\ORM\Persisters\Collection\CollectionPersister;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class NonStrictReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase
 {
     protected function createPersister(
diff --git a/tests/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php
index 8fb07fa..5dd9004 100644
--- a/tests/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php
+++ b/tests/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php
@@ -11,8 +11,10 @@ use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\ORM\Mapping\AssociationMapping;
 use Doctrine\ORM\Persisters\Collection\CollectionPersister;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class ReadOnlyCachedCollectionPersisterTest extends CollectionPersisterTestCase
 {
     protected function createPersister(
diff --git a/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php
index 2b87882..9061d2e 100644
--- a/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php
+++ b/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php
@@ -16,9 +16,11 @@ use Doctrine\ORM\Persisters\Collection\CollectionPersister;
 use Doctrine\Tests\Models\Cache\State;
 use PHPUnit\Framework\Attributes\Group;
 use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionProperty;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class ReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase
 {
     protected function createPersister(
diff --git a/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php
index fe6c050..f3f0d13 100644
--- a/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php
+++ b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php
@@ -14,9 +14,11 @@ use Doctrine\ORM\Mapping\ClassMetadata;
 use Doctrine\ORM\Persisters\Entity\EntityPersister;
 use Doctrine\Tests\Models\Cache\Country;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionProperty;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class NonStrictReadWriteCachedEntityPersisterTest extends EntityPersisterTestCase
 {
     protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister
diff --git a/tests/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php
index 9ced1ac..93e202c 100644
--- a/tests/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php
+++ b/tests/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php
@@ -13,8 +13,10 @@ use Doctrine\ORM\Mapping\ClassMetadata;
 use Doctrine\ORM\Persisters\Entity\EntityPersister;
 use Doctrine\Tests\Models\Cache\Country;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class ReadOnlyCachedEntityPersisterTest extends EntityPersisterTestCase
 {
     protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister
diff --git a/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php
index 40fbd20..f712487 100644
--- a/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php
+++ b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php
@@ -16,9 +16,11 @@ use Doctrine\ORM\Persisters\Entity\EntityPersister;
 use Doctrine\Tests\Models\Cache\Country;
 use PHPUnit\Framework\Attributes\Group;
 use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionProperty;
 
 #[Group('DDC-2183')]
+#[RequiresPhpunit('< 12')]
 class ReadWriteCachedEntityPersisterTest extends EntityPersisterTestCase
 {
     protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister
diff --git a/tests/Tests/ORM/EntityManagerTest.php b/tests/Tests/ORM/EntityManagerTest.php
index e724d9a..fece194 100644
--- a/tests/Tests/ORM/EntityManagerTest.php
+++ b/tests/Tests/ORM/EntityManagerTest.php
@@ -25,11 +25,13 @@ use Generator;
 use PHPUnit\Framework\Assert;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionProperty;
 use stdClass;
 use Symfony\Component\VarExporter\LazyGhostTrait;
 use TypeError;
 
+#[RequiresPhpunit('< 12')]
 class EntityManagerTest extends OrmTestCase
 {
     private EntityManagerMock $entityManager;
diff --git a/tests/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Tests/ORM/Functional/EntityRepositoryTest.php
index 4ea3916..662f209 100644
--- a/tests/Tests/ORM/Functional/EntityRepositoryTest.php
+++ b/tests/Tests/ORM/Functional/EntityRepositoryTest.php
@@ -420,7 +420,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
         $repos                = $this->_em->getRepository(CmsAddress::class);
         $addresses            = $repos->findBy(['user' => $userId]);
 
-        self::assertContainsOnly(CmsAddress::class, $addresses);
+        self::assertContainsOnlyInstancesOf(CmsAddress::class, $addresses);
         self::assertCount(1, $addresses);
         self::assertEquals($addressId, $addresses[0]->id);
     }
@@ -432,7 +432,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
         $repos                = $this->_em->getRepository(CmsAddress::class);
         $addresses            = $repos->findByUser($userId);
 
-        self::assertContainsOnly(CmsAddress::class, $addresses);
+        self::assertContainsOnlyInstancesOf(CmsAddress::class, $addresses);
         self::assertCount(1, $addresses);
         self::assertEquals($addressId, $addresses[0]->id);
     }
diff --git a/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php
index 569ea13..f88704d 100644
--- a/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php
+++ b/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php
@@ -257,13 +257,13 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
 
         $someGroups = $user->groups->slice(0, 2);
 
-        self::assertContainsOnly(CmsGroup::class, $someGroups);
+        self::assertContainsOnlyInstancesOf(CmsGroup::class, $someGroups);
         self::assertCount(2, $someGroups);
         self::assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!");
 
         $otherGroup = $user->groups->slice(2, 1);
 
-        self::assertContainsOnly(CmsGroup::class, $otherGroup);
+        self::assertContainsOnlyInstancesOf(CmsGroup::class, $otherGroup);
         self::assertCount(1, $otherGroup);
         self::assertFalse($user->groups->isInitialized());
 
@@ -305,8 +305,8 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
         $someUsers  = $group->users->slice(0, 2);
         $otherUsers = $group->users->slice(2, 2);
 
-        self::assertContainsOnly(CmsUser::class, $someUsers);
-        self::assertContainsOnly(CmsUser::class, $otherUsers);
+        self::assertContainsOnlyInstancesOf(CmsUser::class, $someUsers);
+        self::assertContainsOnlyInstancesOf(CmsUser::class, $otherUsers);
         self::assertCount(2, $someUsers);
         self::assertCount(2, $otherUsers);
 
diff --git a/tests/Tests/ORM/Functional/QueryCacheTest.php b/tests/Tests/ORM/Functional/QueryCacheTest.php
index 891a3ba..4083dc5 100644
--- a/tests/Tests/ORM/Functional/QueryCacheTest.php
+++ b/tests/Tests/ORM/Functional/QueryCacheTest.php
@@ -9,6 +9,7 @@ use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
 use Doctrine\ORM\Query\ParserResult;
 use Doctrine\Tests\OrmFunctionalTestCase;
 use PHPUnit\Framework\Attributes\Depends;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use Psr\Cache\CacheItemInterface;
 use Psr\Cache\CacheItemPoolInterface;
 use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -104,7 +105,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
 
         $cache->expects(self::once())
             ->method('getItem')
-            ->with(self::isType('string'))
+            ->with(self::isString())
             ->willReturn($cacheItem);
 
         $cache
@@ -116,6 +117,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
         $query->getResult();
     }
 
+    #[RequiresPhpunit('< 12')]
     public function testQueryCacheHitDoesNotSaveParserResult(): void
     {
         $this->_em->getConfiguration()->setQueryCache($this->createMock(CacheItemPoolInterface::class));
@@ -141,7 +143,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
 
         $cache->expects(self::once())
             ->method('getItem')
-            ->with(self::isType('string'))
+            ->with(self::isString())
             ->willReturn($cacheItem);
 
         $cache->expects(self::never())
diff --git a/tests/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Tests/ORM/Functional/SingleTableInheritanceTest.php
index f3fa005..099e5dd 100644
--- a/tests/Tests/ORM/Functional/SingleTableInheritanceTest.php
+++ b/tests/Tests/ORM/Functional/SingleTableInheritanceTest.php
@@ -183,7 +183,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
         $contracts = $this->_em->getRepository(CompanyContract::class)->findAll();
 
         self::assertCount(3, $contracts);
-        self::assertContainsOnly(CompanyContract::class, $contracts);
+        self::assertContainsOnlyInstancesOf(CompanyContract::class, $contracts);
     }
 
     public function testFindAllForChildClass(): void
@@ -212,7 +212,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
         $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult();
 
         self::assertCount(3, $contracts);
-        self::assertContainsOnly(CompanyContract::class, $contracts);
+        self::assertContainsOnlyInstancesOf(CompanyContract::class, $contracts);
     }
 
     public function testQueryForChildClass(): void
@@ -230,7 +230,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
 
         $contracts = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson p')->getResult();
         self::assertCount(3, $contracts);
-        self::assertContainsOnly(CompanyContract::class, $contracts);
+        self::assertContainsOnlyInstancesOf(CompanyContract::class, $contracts);
     }
 
     public function testQueryScalarWithDiscriminatorValue(): void
diff --git a/tests/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Tests/ORM/Functional/Ticket/DDC117Test.php
index dba78b9..302581b 100644
--- a/tests/Tests/ORM/Functional/Ticket/DDC117Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/DDC117Test.php
@@ -288,7 +288,7 @@ class DDC117Test extends OrmFunctionalTestCase
 
         $translations = $article->getTranslations();
         self::assertFalse($translations->isInitialized());
-        self::assertContainsOnly(DDC117Translation::class, $translations);
+        self::assertContainsOnlyInstancesOf(DDC117Translation::class, $translations);
         self::assertTrue($translations->isInitialized());
     }
 
@@ -298,7 +298,7 @@ class DDC117Test extends OrmFunctionalTestCase
         $editor = $this->loadEditorFixture();
 
         self::assertFalse($editor->reviewingTranslations->isInitialized());
-        self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations);
+        self::assertContainsOnlyInstancesOf(DDC117Translation::class, $editor->reviewingTranslations);
         self::assertTrue($editor->reviewingTranslations->isInitialized());
 
         $this->_em->clear();
@@ -306,7 +306,7 @@ class DDC117Test extends OrmFunctionalTestCase
         $dql    = 'SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE e.id = ?1';
         $editor = $this->_em->createQuery($dql)->setParameter(1, $editor->id)->getSingleResult();
         self::assertTrue($editor->reviewingTranslations->isInitialized());
-        self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations);
+        self::assertContainsOnlyInstancesOf(DDC117Translation::class, $editor->reviewingTranslations);
     }
 
     #[Group('DDC-117')]
@@ -344,7 +344,7 @@ class DDC117Test extends OrmFunctionalTestCase
                            ->getSingleResult();
 
         self::assertInstanceOf(DDC117Translation::class, $trans);
-        self::assertContainsOnly(DDC117Editor::class, $trans->reviewedByEditors);
+        self::assertContainsOnlyInstancesOf(DDC117Editor::class, $trans->reviewedByEditors);
         self::assertCount(1, $trans->reviewedByEditors);
     }
 
diff --git a/tests/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3042Test.php
index c20799d..e590c16 100644
--- a/tests/Tests/ORM/Functional/Ticket/DDC3042Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/DDC3042Test.php
@@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\GeneratedValue;
 use Doctrine\ORM\Mapping\Id;
 use Doctrine\Tests\OrmFunctionalTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-3042')]
 class DDC3042Test extends OrmFunctionalTestCase
@@ -21,6 +22,7 @@ class DDC3042Test extends OrmFunctionalTestCase
         $this->createSchemaForModels(DDC3042Foo::class, DDC3042Bar::class);
     }
 
+    #[RequiresPhpunit('< 12')]
     public function testSQLGenerationDoesNotProvokeAliasCollisions(): void
     {
         self::assertStringNotMatchesFormat(
diff --git a/tests/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3170Test.php
index d3248f2..1276601 100644
--- a/tests/Tests/ORM/Functional/Ticket/DDC3170Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/DDC3170Test.php
@@ -56,7 +56,7 @@ class DDC3170Test extends OrmFunctionalTestCase
                   ->getResult(AbstractQuery::HYDRATE_SIMPLEOBJECT);
 
         self::assertCount(1, $result);
-        self::assertContainsOnly(DDC3170ProductJoined::class, $result);
+        self::assertContainsOnlyInstancesOf(DDC3170ProductJoined::class, $result);
 
         $result = $this->_em->createQueryBuilder()
                   ->select('p')
@@ -65,7 +65,7 @@ class DDC3170Test extends OrmFunctionalTestCase
                   ->getResult(AbstractQuery::HYDRATE_SIMPLEOBJECT);
 
         self::assertCount(1, $result);
-        self::assertContainsOnly(DDC3170ProductSingleTable::class, $result);
+        self::assertContainsOnlyInstancesOf(DDC3170ProductSingleTable::class, $result);
     }
 }
 
diff --git a/tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php b/tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php
index 7822a71..a85ccdf 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
 namespace Doctrine\Tests\ORM\Functional\Ticket\GH10049;
 
 use Doctrine\Tests\OrmFunctionalTestCase;
+use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
 
 class GH10049Test extends OrmFunctionalTestCase
 {
@@ -18,7 +19,7 @@ class GH10049Test extends OrmFunctionalTestCase
         );
     }
 
-    /** @doesNotPerformAssertions */
+    #[DoesNotPerformAssertions]
     public function testInheritedReadOnlyPropertyValueCanBeSet(): void
     {
         $child = new ReadOnlyPropertyInheritor(10049);
diff --git a/tests/Tests/ORM/Functional/Ticket/GH10387Test.php b/tests/Tests/ORM/Functional/Ticket/GH10387Test.php
index ccf802a..e456678 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH10387Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH10387Test.php
@@ -10,10 +10,12 @@ use Doctrine\Tests\OrmTestCase;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function array_map;
 
 #[Group('GH-10387')]
+#[RequiresPhpunit('< 12')]
 class GH10387Test extends OrmTestCase
 {
     #[DataProvider('classHierachies')]
diff --git a/tests/Tests/ORM/Functional/Ticket/GH10450Test.php b/tests/Tests/ORM/Functional/Ticket/GH10450Test.php
index 79001b6..7dcc711 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH10450Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH10450Test.php
@@ -9,7 +9,9 @@ use Doctrine\ORM\Mapping\MappingException;
 use Doctrine\Tests\OrmTestCase;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class GH10450Test extends OrmTestCase
 {
     /** @param class-string $className */
diff --git a/tests/Tests/ORM/Functional/Ticket/GH10454Test.php b/tests/Tests/ORM/Functional/Ticket/GH10454Test.php
index 73e0444..d319df7 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH10454Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH10454Test.php
@@ -9,7 +9,9 @@ use Doctrine\ORM\Mapping\MappingException;
 use Doctrine\Tests\OrmTestCase;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class GH10454Test extends OrmTestCase
 {
     /** @param class-string $className */
diff --git a/tests/Tests/ORM/Functional/Ticket/GH10473Test.php b/tests/Tests/ORM/Functional/Ticket/GH10473Test.php
index 550080d..fd853f7 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH10473Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH10473Test.php
@@ -8,7 +8,9 @@ use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
 use Doctrine\ORM\Tools\ResolveTargetEntityListener;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class GH10473Test extends OrmTestCase
 {
     public function testMappedSuperclassAssociationsCanBeResolvedToEntities(): void
diff --git a/tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php b/tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php
index b327456..ee5e891 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php
@@ -7,7 +7,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket\GH10661;
 use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\ORM\Tools\SchemaValidator;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 final class GH10661Test extends OrmTestCase
 {
     /** @var EntityManagerInterface */
diff --git a/tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php b/tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php
index b73e28e..9a91c06 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php
@@ -7,7 +7,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket\GH11037;
 use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\ORM\Tools\SchemaValidator;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 final class GH11037Test extends OrmTestCase
 {
     /** @var EntityManagerInterface */
diff --git a/tests/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Tests/ORM/Functional/Ticket/GH8061Test.php
index 9e02de5..10d3310 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH8061Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH8061Test.php
@@ -12,10 +12,12 @@ use Doctrine\ORM\Mapping\GeneratedValue;
 use Doctrine\ORM\Mapping\Id;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function sprintf;
 
 #[Group('GH8061')]
+#[RequiresPhpunit('< 12')]
 final class GH8061Test extends OrmTestCase
 {
     public static function setUpBeforeClass(): void
diff --git a/tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php b/tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php
index 444955c..c0ff718 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php
@@ -7,7 +7,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class GH8415ToManyAssociationTest extends OrmTestCase
 {
     public function testToManyAssociationOnBaseClassAllowedWhenThereAreMappedSuperclassesAsChildren(): void
diff --git a/tests/Tests/ORM/Functional/Ticket/GH8914Test.php b/tests/Tests/ORM/Functional/Ticket/GH8914Test.php
index 328aadc..9b44d8b 100644
--- a/tests/Tests/ORM/Functional/Ticket/GH8914Test.php
+++ b/tests/Tests/ORM/Functional/Ticket/GH8914Test.php
@@ -15,7 +15,9 @@ use Doctrine\ORM\Mapping\MappedSuperclass;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 final class GH8914Test extends OrmTestCase
 {
     #[DoesNotPerformAssertions]
diff --git a/tests/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Tests/ORM/Hydration/AbstractHydratorTest.php
index d83ee1a..96377d1 100644
--- a/tests/Tests/ORM/Hydration/AbstractHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/AbstractHydratorTest.php
@@ -17,11 +17,13 @@ use Doctrine\Tests\Models\Hydration\SimpleEntity;
 use Doctrine\Tests\OrmFunctionalTestCase;
 use PHPUnit\Framework\Attributes\CoversClass;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use PHPUnit\Framework\MockObject\MockObject;
 
 use function iterator_to_array;
 
 #[CoversClass(AbstractHydrator::class)]
+#[RequiresPhpunit('< 12')]
 class AbstractHydratorTest extends OrmFunctionalTestCase
 {
     private EventManager&MockObject $mockEventManager;
diff --git a/tests/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Tests/ORM/Hydration/ArrayHydratorTest.php
index db3c5bd..f2b3345 100644
--- a/tests/Tests/ORM/Hydration/ArrayHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/ArrayHydratorTest.php
@@ -14,7 +14,9 @@ use Doctrine\Tests\Models\Forum\ForumBoard;
 use Doctrine\Tests\Models\Forum\ForumCategory;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class ArrayHydratorTest extends HydrationTestCase
 {
     /** @phpstan-return list<array{int|string}> */
diff --git a/tests/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Tests/ORM/Hydration/CustomHydratorTest.php
index 2e2dcf3..d70b350 100644
--- a/tests/Tests/ORM/Hydration/CustomHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/CustomHydratorTest.php
@@ -5,7 +5,9 @@ declare(strict_types=1);
 namespace Doctrine\Tests\ORM\Hydration;
 
 use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class CustomHydratorTest extends HydrationTestCase
 {
     public function testCustomHydrator(): void
diff --git a/tests/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php
index 5268172..8b736d3 100644
--- a/tests/Tests/ORM/Hydration/ObjectHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php
@@ -31,11 +31,13 @@ use Doctrine\Tests\Models\Hydration\SimpleEntity;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
 use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function count;
 use function property_exists;
 use function sys_get_temp_dir;
 
+#[RequiresPhpunit('< 12')]
 class ObjectHydratorTest extends HydrationTestCase
 {
     /** @phpstan-return list<array{mixed}> */
diff --git a/tests/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php
index 0c20eab..147b758 100644
--- a/tests/Tests/ORM/Hydration/ResultSetMappingTest.php
+++ b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php
@@ -12,10 +12,12 @@ use Doctrine\Tests\Models\Legacy\LegacyUser;
 use Doctrine\Tests\Models\Legacy\LegacyUserReference;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Description of ResultSetMappingTest
  */
+#[RequiresPhpunit('< 12')]
 class ResultSetMappingTest extends OrmTestCase
 {
     private ResultSetMapping $_rsm;
diff --git a/tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php b/tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php
index b87bc6c..12c1b77 100644
--- a/tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php
@@ -8,9 +8,11 @@ use Doctrine\ORM\Exception\MultipleSelectorsFoundException;
 use Doctrine\ORM\Internal\Hydration\ScalarColumnHydrator;
 use Doctrine\ORM\Query\ResultSetMapping;
 use Doctrine\Tests\Models\CMS\CmsUser;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function sprintf;
 
+#[RequiresPhpunit('< 12')]
 class ScalarColumnHydratorTest extends HydrationTestCase
 {
     /**
diff --git a/tests/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Tests/ORM/Hydration/ScalarHydratorTest.php
index baa27f3..d6febd1 100644
--- a/tests/Tests/ORM/Hydration/ScalarHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/ScalarHydratorTest.php
@@ -8,7 +8,9 @@ use Doctrine\ORM\Internal\Hydration\ScalarHydrator;
 use Doctrine\ORM\Query\ResultSetMapping;
 use Doctrine\Tests\Models\CMS\CmsUser;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class ScalarHydratorTest extends HydrationTestCase
 {
     /**
diff --git a/tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php
index bf2f658..e055654 100644
--- a/tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php
@@ -23,7 +23,9 @@ use Doctrine\Tests\Models\Issue5989\Issue5989Employee;
 use Doctrine\Tests\Models\Issue5989\Issue5989Manager;
 use Doctrine\Tests\Models\Issue5989\Issue5989Person;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class SimpleObjectHydratorTest extends HydrationTestCase
 {
     #[Group('DDC-1470')]
diff --git a/tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php
index 87d8ede..8c43d95 100644
--- a/tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php
+++ b/tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php
@@ -10,7 +10,9 @@ use Doctrine\ORM\Query\ResultSetMapping;
 use Doctrine\Tests\Models\CMS\CmsUser;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class SingleScalarHydratorTest extends HydrationTestCase
 {
     /** @return Generator<int, array{list<array<string,mixed>>,mixed}> */
diff --git a/tests/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Tests/ORM/Id/AssignedGeneratorTest.php
index 09755b2..be3ef1f 100644
--- a/tests/Tests/ORM/Id/AssignedGeneratorTest.php
+++ b/tests/Tests/ORM/Id/AssignedGeneratorTest.php
@@ -12,10 +12,12 @@ use Doctrine\ORM\Mapping\Entity;
 use Doctrine\ORM\Mapping\Id;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * AssignedGeneratorTest
  */
+#[RequiresPhpunit('< 12')]
 class AssignedGeneratorTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php
index 522b0fc..5ca3266 100644
--- a/tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php
+++ b/tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php
@@ -14,9 +14,11 @@ use Doctrine\Tests\Models\DDC117\DDC117Article;
 use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-1845')]
 #[Group('DDC-2459')]
+#[RequiresPhpunit('< 12')]
 class AnsiQuoteStrategyTest extends OrmTestCase
 {
     private AnsiQuoteStrategy $strategy;
@@ -146,3 +148,4 @@ class AnsiQuoteStrategyTest extends OrmTestCase
         self::assertEquals('user_id_seq', $this->strategy->getSequenceName($definition, $class, $this->platform));
     }
 }
+
diff --git a/tests/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Tests/ORM/Mapping/AttributeDriverTest.php
index b16ec78..dfa2cd7 100644
--- a/tests/Tests/ORM/Mapping/AttributeDriverTest.php
+++ b/tests/Tests/ORM/Mapping/AttributeDriverTest.php
@@ -13,8 +13,10 @@ use Doctrine\ORM\Mapping\MappingAttribute;
 use Doctrine\Persistence\Mapping\Driver\MappingDriver;
 use Doctrine\Tests\ORM\Mapping\Fixtures\AttributeEntityWithNestedJoinColumns;
 use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use stdClass;
 
+#[RequiresPhpunit('< 12')]
 class AttributeDriverTest extends MappingDriverTestCase
 {
     protected function loadDriver(): MappingDriver
diff --git a/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
index 2864211..d198469 100644
--- a/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
+++ b/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
@@ -33,12 +33,14 @@ use Doctrine\Tests\OrmTestCase;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function assert;
 use function serialize;
 use function sprintf;
 use function unserialize;
 
+#[RequiresPhpunit('< 12')]
 class BasicInheritanceMappingTest extends OrmTestCase
 {
     private ClassMetadataFactory $cmf;
diff --git a/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php
index 294ac3d..f4d4fd1 100644
--- a/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php
+++ b/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php
@@ -13,11 +13,13 @@ use Doctrine\ORM\Mapping\Id;
 use Doctrine\ORM\Mapping\Table;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionProperty;
 
 class ClassMetadataLoadEventTest extends OrmTestCase
 {
     #[Group('DDC-1610')]
+    #[RequiresPhpunit('< 12')]
     public function testEvent(): void
     {
         $em              = $this->getTestEntityManager();
diff --git a/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php
index b808f31..4d1a012 100644
--- a/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php
+++ b/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php
@@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
 use Doctrine\Tests\Models\NonPublicSchemaJoins\User as NonPublicSchemaUser;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function assert;
 use function enum_exists;
@@ -21,6 +22,7 @@ class DefaultQuoteStrategyTest extends OrmTestCase
 {
     #[Group('DDC-3590')]
     #[Group('DDC-1316')]
+    #[RequiresPhpunit('< 12')]
     public function testGetJoinTableName(): void
     {
         $em       = $this->getTestEntityManager();
diff --git a/tests/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Tests/ORM/Mapping/QuoteStrategyTest.php
index 8a8eec6..2530d31 100644
--- a/tests/Tests/ORM/Mapping/QuoteStrategyTest.php
+++ b/tests/Tests/ORM/Mapping/QuoteStrategyTest.php
@@ -15,8 +15,10 @@ use Doctrine\Tests\Models\DDC117\DDC117Article;
 use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-1845')]
+#[RequiresPhpunit('< 12')]
 class QuoteStrategyTest extends OrmTestCase
 {
     private DefaultQuoteStrategy $strategy;
diff --git a/tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php
index 981fe14..726e722 100644
--- a/tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php
+++ b/tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php
@@ -9,9 +9,11 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver;
 use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver;
 use Doctrine\Tests\Models\DDC889\DDC889Class;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use const DIRECTORY_SEPARATOR;
 
+#[RequiresPhpunit('< 12')]
 class StaticPHPMappingDriverTest extends MappingDriverTestCase
 {
     protected function loadDriver(): MappingDriver
diff --git a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php
index 474c623..b2d465a 100644
--- a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php
+++ b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php
@@ -32,11 +32,13 @@ use Doctrine\Tests\Models\ValueObjects\Name;
 use Doctrine\Tests\Models\ValueObjects\Person;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function substr_count;
 
 use const DIRECTORY_SEPARATOR;
 
+#[RequiresPhpunit('< 12')]
 class XmlMappingDriverTest extends MappingDriverTestCase
 {
     protected function loadDriver(): MappingDriver
diff --git a/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php
index 3f2d0ab..8ae8acb 100644
--- a/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php
+++ b/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php
@@ -11,7 +11,9 @@ use Doctrine\Tests\Models\GeoNames\Admin1;
 use Doctrine\Tests\Models\GeoNames\Admin1AlternateName;
 use Doctrine\Tests\Models\GeoNames\Country;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class BasicEntityPersisterCompositeTypeParametersTest extends OrmTestCase
 {
     protected BasicEntityPersister $persister;
diff --git a/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php
index 9ab9e32..1229cdf 100644
--- a/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php
+++ b/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php
@@ -12,7 +12,9 @@ use Doctrine\ORM\Persisters\Exception\CantUseInOperatorOnCompositeKeys;
 use Doctrine\Tests\Mocks\EntityManagerMock;
 use Doctrine\Tests\Models\GeoNames\Admin1AlternateName;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class BasicEntityPersisterCompositeTypeSqlTest extends OrmTestCase
 {
     protected BasicEntityPersister $persister;
diff --git a/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php
index f0ab8a0..c072740 100644
--- a/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php
+++ b/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php
@@ -21,11 +21,13 @@ use Doctrine\Tests\Models\CustomType\CustomTypeParent;
 use Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use ReflectionMethod;
 
 use function array_slice;
 use function enum_exists;
 
+#[RequiresPhpunit('< 12')]
 class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase
 {
     protected BasicEntityPersister $persister;
diff --git a/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php b/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php
index e3a78db..f19f349 100644
--- a/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php
+++ b/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php
@@ -15,6 +15,7 @@ use Doctrine\Tests\Models\ManyToManyPersister\ParentClass;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\CoversClass;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function enum_exists;
 
@@ -23,6 +24,7 @@ final class ManyToManyPersisterTest extends OrmTestCase
 {
     #[Group('GH-6991')]
     #[Group('ManyToManyPersister')]
+    #[RequiresPhpunit('< 12')]
     public function testDeleteManyToManyCollection(): void
     {
         $driver = $this->createMock(Driver::class);
diff --git a/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
index 16be0ce..a9217b1 100644
--- a/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
+++ b/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
@@ -8,12 +8,14 @@ use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\ORM\Query;
 use Doctrine\Tests\Mocks\CustomTreeWalkerJoin;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Test case for custom AST walking and adding new joins.
  *
  * @link        http://www.doctrine-project.org
  */
+#[RequiresPhpunit('< 12')]
 class CustomTreeWalkersJoinTest extends OrmTestCase
 {
     private EntityManagerInterface $em;
diff --git a/tests/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Tests/ORM/Query/CustomTreeWalkersTest.php
index 83e001f..238b584 100644
--- a/tests/Tests/ORM/Query/CustomTreeWalkersTest.php
+++ b/tests/Tests/ORM/Query/CustomTreeWalkersTest.php
@@ -22,6 +22,7 @@ use Doctrine\ORM\Query\TreeWalkerAdapter;
 use Doctrine\Tests\Mocks\CustomTreeWalkerJoin;
 use Doctrine\Tests\Models\CMS\CmsUser;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function array_merge;
 use function count;
@@ -31,6 +32,7 @@ use function count;
  *
  * @link        http://www.doctrine-project.org
  */
+#[RequiresPhpunit('< 12')]
 class CustomTreeWalkersTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Tests/ORM/Query/DeleteSqlGenerationTest.php
index dca376a..5dde0c9 100644
--- a/tests/Tests/ORM/Query/DeleteSqlGenerationTest.php
+++ b/tests/Tests/ORM/Query/DeleteSqlGenerationTest.php
@@ -7,6 +7,7 @@ namespace Doctrine\Tests\ORM\Query;
 use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Test case for testing the saving and referencing of query identifiers.
@@ -17,6 +18,7 @@ use PHPUnit\Framework\Attributes\Group;
  *              testcases later since we'll have a lot of them and we might want to have special SQL
  *              generation tests for some dbms specific SQL syntaxes.
  */
+#[RequiresPhpunit('< 12')]
 class DeleteSqlGenerationTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/Query/ExprTest.php b/tests/Tests/ORM/Query/ExprTest.php
index b3ff41f..9277432 100644
--- a/tests/Tests/ORM/Query/ExprTest.php
+++ b/tests/Tests/ORM/Query/ExprTest.php
@@ -23,6 +23,7 @@ use Generator;
 use InvalidArgumentException;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Test case for the DQL Expr class used for generating DQL snippets through
@@ -30,6 +31,7 @@ use PHPUnit\Framework\Attributes\Group;
  *
  * @link        http://www.phpdoctrine.org
  */
+#[RequiresPhpunit('< 12')]
 class ExprTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/Query/FilterCollectionTest.php b/tests/Tests/ORM/Query/FilterCollectionTest.php
index 5efe85a..60b4ac6 100644
--- a/tests/Tests/ORM/Query/FilterCollectionTest.php
+++ b/tests/Tests/ORM/Query/FilterCollectionTest.php
@@ -9,10 +9,12 @@ use Doctrine\ORM\Query\Filter\SQLFilter;
 use Doctrine\Tests\Mocks\EntityManagerMock;
 use Doctrine\Tests\OrmTestCase;
 use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Test case for FilterCollection
  */
+#[RequiresPhpunit('< 12')]
 class FilterCollectionTest extends OrmTestCase
 {
     private EntityManagerMock $em;
@@ -34,7 +36,7 @@ class FilterCollectionTest extends OrmTestCase
         $enabledFilters = $filterCollection->getEnabledFilters();
 
         self::assertCount(1, $enabledFilters);
-        self::assertContainsOnly(MyFilter::class, $enabledFilters);
+        self::assertContainsOnlyInstancesOf(MyFilter::class, $enabledFilters);
 
         $filter2 = $filterCollection->disable('testFilter');
         self::assertCount(0, $filterCollection->getEnabledFilters());
@@ -50,7 +52,7 @@ class FilterCollectionTest extends OrmTestCase
         self::assertNotSame($filter4, $filter5);
 
         self::assertCount(1, $enabledFilters);
-        self::assertContainsOnly(MyFilter::class, $enabledFilters);
+        self::assertContainsOnlyInstancesOf(MyFilter::class, $enabledFilters);
     }
 
     public function testSuspend(): void
diff --git a/tests/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php
index 02b42fb..5890c88 100644
--- a/tests/Tests/ORM/Query/LanguageRecognitionTest.php
+++ b/tests/Tests/ORM/Query/LanguageRecognitionTest.php
@@ -20,7 +20,9 @@ use Doctrine\Tests\Mocks\NullSqlWalker;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class LanguageRecognitionTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/Query/NativeQueryTest.php b/tests/Tests/ORM/Query/NativeQueryTest.php
index 0e68389..e6b1b55 100644
--- a/tests/Tests/ORM/Query/NativeQueryTest.php
+++ b/tests/Tests/ORM/Query/NativeQueryTest.php
@@ -10,7 +10,9 @@ use Doctrine\ORM\Query\ResultSetMapping;
 use Doctrine\ORM\UnitOfWork;
 use Doctrine\Tests\Mocks\EntityManagerMock;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class NativeQueryTest extends OrmTestCase
 {
     /** @var EntityManagerMock */
diff --git a/tests/Tests/ORM/Query/ParserResultTest.php b/tests/Tests/ORM/Query/ParserResultTest.php
index af9831b..55e7501 100644
--- a/tests/Tests/ORM/Query/ParserResultTest.php
+++ b/tests/Tests/ORM/Query/ParserResultTest.php
@@ -8,6 +8,7 @@ use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
 use Doctrine\ORM\Query\ParserResult;
 use Doctrine\ORM\Query\ResultSetMapping;
 use LogicException;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use PHPUnit\Framework\TestCase;
 
 class ParserResultTest extends TestCase
@@ -35,6 +36,7 @@ class ParserResultTest extends TestCase
         $this->parserResult->getSqlExecutor();
     }
 
+    #[RequiresPhpunit('< 12')]
     public function testSetGetSqlExecutor(): void
     {
         $executor = $this->getMockForAbstractClass(AbstractSqlExecutor::class);
diff --git a/tests/Tests/ORM/Query/ParserTest.php b/tests/Tests/ORM/Query/ParserTest.php
index c260455..edce149 100644
--- a/tests/Tests/ORM/Query/ParserTest.php
+++ b/tests/Tests/ORM/Query/ParserTest.php
@@ -13,8 +13,10 @@ use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use stdClass;
 
+#[RequiresPhpunit('< 12')]
 class ParserTest extends OrmTestCase
 {
     #[Group('DDC-3715')]
diff --git a/tests/Tests/ORM/Query/QueryTest.php b/tests/Tests/ORM/Query/QueryTest.php
index a2bfed1..40210b2 100644
--- a/tests/Tests/ORM/Query/QueryTest.php
+++ b/tests/Tests/ORM/Query/QueryTest.php
@@ -35,6 +35,7 @@ use Doctrine\Tests\OrmTestCase;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use Psr\Cache\CacheItemInterface;
 use Psr\Cache\CacheItemPoolInterface;
 use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -42,6 +43,7 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter;
 use function array_map;
 use function enum_exists;
 
+#[RequiresPhpunit('< 12')]
 class QueryTest extends OrmTestCase
 {
     private EntityManagerMock $entityManager;
@@ -592,6 +594,7 @@ class QueryTest extends OrmTestCase
             ->getSQL();
     }
 
+    #[RequiresPhpunit('< 12')]
     private function createConnection(Result ...$results): Connection
     {
         $driverConnection = $this->createMock(Driver\Connection::class);
diff --git a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php
index 02c4921..bf2a426 100644
--- a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php
+++ b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php
@@ -31,12 +31,14 @@ use Doctrine\Tests\OrmTestCase;
 use Exception;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function class_exists;
 
 // DBAL 3 compatibility
 class_exists('Doctrine\\DBAL\\Platforms\\SqlitePlatform');
 
+#[RequiresPhpunit('< 12')]
 class SelectSqlGenerationTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/Query/SqlWalkerTest.php b/tests/Tests/ORM/Query/SqlWalkerTest.php
index 87daa3e..356ce63 100644
--- a/tests/Tests/ORM/Query/SqlWalkerTest.php
+++ b/tests/Tests/ORM/Query/SqlWalkerTest.php
@@ -10,11 +10,13 @@ use Doctrine\ORM\Query\SqlWalker;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\CoversClass;
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Tests for {@see \Doctrine\ORM\Query\SqlWalker}
  */
 #[CoversClass(SqlWalker::class)]
+#[RequiresPhpunit('< 12')]
 class SqlWalkerTest extends OrmTestCase
 {
     private SqlWalker $sqlWalker;
diff --git a/tests/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Tests/ORM/Query/UpdateSqlGenerationTest.php
index 88b3e0b..83d5019 100644
--- a/tests/Tests/ORM/Query/UpdateSqlGenerationTest.php
+++ b/tests/Tests/ORM/Query/UpdateSqlGenerationTest.php
@@ -9,6 +9,7 @@ use Doctrine\ORM\EntityManagerInterface;
 use Doctrine\Tests\DbalTypes\NegativeToPositiveType;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 /**
  * Test case for testing the saving and referencing of query identifiers.
@@ -19,6 +20,7 @@ use PHPUnit\Framework\Attributes\Group;
  *              testcases later since we'll have a lot of them and we might want to have special SQL
  *              generation tests for some dbms specific SQL syntaxes.
  */
+#[RequiresPhpunit('< 12')]
 class UpdateSqlGenerationTest extends OrmTestCase
 {
     private EntityManagerInterface $entityManager;
diff --git a/tests/Tests/ORM/QueryBuilderTest.php b/tests/Tests/ORM/QueryBuilderTest.php
index fd610bc..6115d20 100644
--- a/tests/Tests/ORM/QueryBuilderTest.php
+++ b/tests/Tests/ORM/QueryBuilderTest.php
@@ -23,6 +23,7 @@ use Doctrine\Tests\Models\CMS\CmsUser;
 use Doctrine\Tests\OrmTestCase;
 use InvalidArgumentException;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function array_filter;
 use function class_exists;
@@ -31,6 +32,7 @@ use function class_exists;
  * Test case for the QueryBuilder class used to build DQL query string in a
  * object oriented way.
  */
+#[RequiresPhpunit('< 12')]
 class QueryBuilderTest extends OrmTestCase
 {
     private EntityManagerMock $entityManager;
diff --git a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php
index 83d3988..0bcffbd 100644
--- a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php
+++ b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php
@@ -111,7 +111,7 @@ class DefaultRepositoryFactoryTest extends TestCase
     private function buildClassMetadata(string $className): ClassMetadata&MockObject
     {
         $metadata = $this->createMock(ClassMetadata::class);
-        $metadata->method('getName')->will(self::returnValue($className));
+        $metadata->method('getName')->willReturn($className);
         $metadata->name = $className;
 
         $metadata->customRepositoryClassName = null;
diff --git a/tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php
index 26fc5ab..d9f1d00 100644
--- a/tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php
+++ b/tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php
@@ -15,9 +15,11 @@ use Doctrine\ORM\Mapping\Id;
 use Doctrine\ORM\Mapping\MappingException;
 use Doctrine\ORM\Tools\AttachEntityListenersListener;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function func_get_args;
 
+#[RequiresPhpunit('< 12')]
 class AttachEntityListenersListenerTest extends OrmTestCase
 {
     private EntityManagerInterface $em;
diff --git a/tests/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Tests/ORM/Tools/Console/MetadataFilterTest.php
index 5db5f94..0b4f8fe 100644
--- a/tests/Tests/ORM/Tools/Console/MetadataFilterTest.php
+++ b/tests/Tests/ORM/Tools/Console/MetadataFilterTest.php
@@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\Id;
 use Doctrine\ORM\Tools\Console\MetadataFilter;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function count;
 
@@ -18,6 +19,7 @@ use function count;
  * Tests for {@see \Doctrine\ORM\Tools\Console\MetadataFilter}
  */
 #[CoversClass(MetadataFilter::class)]
+#[RequiresPhpunit('< 12')]
 class MetadataFilterTest extends OrmTestCase
 {
     private ClassMetadataFactory $cmf;
diff --git a/tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php
index 0b64126..d2b1f2e 100644
--- a/tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php
@@ -7,7 +7,9 @@ namespace Doctrine\Tests\ORM\Tools\Pagination;
 use Doctrine\DBAL\Platforms\SQLServerPlatform;
 use Doctrine\ORM\Query;
 use Doctrine\ORM\Tools\Pagination\CountOutputWalker;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class CountOutputWalkerTest extends PaginationTestCase
 {
     public function testCountQuery(): void
diff --git a/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php
index 6a223e6..955f6ec 100644
--- a/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php
@@ -7,9 +7,11 @@ namespace Doctrine\Tests\ORM\Tools\Pagination;
 use Doctrine\ORM\Query;
 use Doctrine\ORM\Tools\Pagination\CountWalker;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use RuntimeException;
 
 #[Group('DDC-1613')]
+#[RequiresPhpunit('< 12')]
 class CountWalkerTest extends PaginationTestCase
 {
     public function testCountQuery(): void
diff --git a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
index c009fcc..140b09c 100644
--- a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
@@ -10,8 +10,10 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
 use Doctrine\ORM\Query;
 use Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use Symfony\Component\Cache\Adapter\ArrayAdapter;
 
+#[RequiresPhpunit('< 12')]
 final class LimitSubqueryOutputWalkerTest extends PaginationTestCase
 {
     public function testSubqueryClonedCompletely(): void
diff --git a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php
index f9c3ba7..8cfa2b6 100644
--- a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php
@@ -8,8 +8,10 @@ use Doctrine\ORM\Query;
 use Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker;
 use Doctrine\ORM\Tools\Pagination\Paginator;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-1613')]
+#[RequiresPhpunit('< 12')]
 class LimitSubqueryWalkerTest extends PaginationTestCase
 {
     public function testLimitSubquery(): void
diff --git a/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php
index 16f0c28..73dc181 100644
--- a/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php
@@ -16,10 +16,12 @@ use Doctrine\ORM\Query;
 use Doctrine\ORM\Query\QueryException;
 use Doctrine\ORM\Tools\Pagination\Paginator;
 use Doctrine\Tests\OrmTestCase;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use PHPUnit\Framework\MockObject\MockObject;
 
 use function enum_exists;
 
+#[RequiresPhpunit('< 12')]
 class PaginatorTest extends OrmTestCase
 {
     private Connection&MockObject $connection;
diff --git a/tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php
index 11282b0..9ca816d 100644
--- a/tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php
@@ -12,7 +12,9 @@ use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity;
 use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneIdForeignKeyEntity;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class RootTypeWalkerTest extends PaginationTestCase
 {
     protected function setUp(): void
diff --git a/tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php
index 4889b98..de4182c 100644
--- a/tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php
+++ b/tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php
@@ -10,8 +10,10 @@ use Doctrine\ORM\Tools\Pagination\WhereInWalker;
 use Generator;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 #[Group('DDC-1613')]
+#[RequiresPhpunit('< 12')]
 class WhereInWalkerTest extends PaginationTestCase
 {
     #[DataProvider('exampleQueries')]
diff --git a/tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php
index 779a774..acbc864 100644
--- a/tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php
+++ b/tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php
@@ -21,7 +21,9 @@ use Doctrine\ORM\Tools\ResolveTargetEntityListener;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\CoversNothing;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class ResolveTargetEntityListenerTest extends OrmTestCase
 {
     private EntityManagerInterface $em;
diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php
index 0a11c8f..cd8f640 100644
--- a/tests/Tests/ORM/Tools/SchemaToolTest.php
+++ b/tests/Tests/ORM/Tools/SchemaToolTest.php
@@ -48,6 +48,7 @@ use Doctrine\Tests\Models\Forum\ForumUser;
 use Doctrine\Tests\Models\NullDefault\NullDefaultColumn;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
 use function array_map;
 use function class_exists;
@@ -56,6 +57,7 @@ use function current;
 use function enum_exists;
 use function method_exists;
 
+#[RequiresPhpunit('< 12')]
 class SchemaToolTest extends OrmTestCase
 {
     public function testAddUniqueIndexForUniqueFieldAttribute(): void
diff --git a/tests/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Tests/ORM/Tools/SchemaValidatorTest.php
index 8942380..a5d2ed3 100644
--- a/tests/Tests/ORM/Tools/SchemaValidatorTest.php
+++ b/tests/Tests/ORM/Tools/SchemaValidatorTest.php
@@ -30,7 +30,9 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCart;
 use Doctrine\Tests\OrmTestCase;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 
+#[RequiresPhpunit('< 12')]
 class SchemaValidatorTest extends OrmTestCase
 {
     private EntityManagerInterface|null $em = null;
diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php
index 7faad81..587112f 100644
--- a/tests/Tests/ORM/UnitOfWorkTest.php
+++ b/tests/Tests/ORM/UnitOfWorkTest.php
@@ -37,6 +37,7 @@ use Exception as BaseException;
 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\Attributes\Group;
 use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\Attributes\RequiresPhpunit;
 use stdClass;
 
 use function enum_exists;
@@ -532,6 +533,7 @@ class UnitOfWorkTest extends OrmTestCase
     }
 
     #[Group('#7946')] // Throw OptimisticLockException when connection::commit() returns false.
+    #[RequiresPhpunit('< 12')]
     public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(): void
     {
         $platform = $this->getMockBuilder(AbstractPlatform::class)
