From ad15a4dd77307028e1c24d7881ff47eda4c299c4 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 28 Oct 2025 09:00:44 +0100 Subject: [PATCH 1/3] Enable native lazy objects whenever possible. The LazyGhostTrait will be removed from symfony/var-exporter:8. --- .../unit/Codeception/Module/Doctrine2Test.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/unit/Codeception/Module/Doctrine2Test.php b/tests/unit/Codeception/Module/Doctrine2Test.php index ad09560..2bc9ccb 100644 --- a/tests/unit/Codeception/Module/Doctrine2Test.php +++ b/tests/unit/Codeception/Module/Doctrine2Test.php @@ -81,18 +81,18 @@ protected function _setUp() $connection = DriverManager::getConnection(['driver' => $sqliteDriver, 'memory' => true]); if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3', '>=')) { - $this->em = new EntityManager( - $connection, - ORMSetup::createAttributeMetadataConfiguration([$dir], true) - ); + $configuration = ORMSetup::createAttributeMetadataConfiguration([$dir], true); } else { - $this->em = new EntityManager( - $connection, - // @phpstan-ignore-next-line - ORMSetup::createAnnotationMetadataConfiguration([$dir], true) - ); + // @phpstan-ignore-next-line + $configuration = ORMSetup::createAnnotationMetadataConfiguration([$dir], true); } + if (PHP_VERSION_ID >= 80400 && method_exists($configuration, 'enableNativeLazyObjects')) { + $configuration->enableNativeLazyObjects(true); + } + + $this->em = new EntityManager($connection, $configuration); + (new SchemaTool($this->em))->createSchema([ $this->em->getClassMetadata(CompositePrimaryKeyEntity::class), $this->em->getClassMetadata(PlainEntity::class), From 3e6d1d7f13b2ca619342a8a908755c530c241236 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 28 Oct 2025 08:51:42 +0100 Subject: [PATCH 2/3] Fix usage of deprecated phpstan config option --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 1805e37..f0dad3e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,7 +8,6 @@ parameters: - tests/data/doctrine_fixtures/TestFixture1.php - tests/data/doctrine_fixtures/TestFixture2.php - tests/_support/UnitTester.php - checkMissingIterableValueType: false reportUnmatchedIgnoredErrors: true ignoreErrors: - path: tests/ @@ -21,3 +20,4 @@ parameters: message: '#Method \S+ has no return type specified#' - path: tests/ message: '#(?:Method|Property) .+ with generic (?:interface|class) \S+ does not specify its types#' + - identifier: missingType.iterableValue From 7be329c2927a4d305623c49693ed84197007fcb3 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 28 Oct 2025 08:46:57 +0100 Subject: [PATCH 3/3] Set $accessRawFieldValues explicitly Fixes a deprecation warning when using doctrine/collections:2.4 See https://github.com/doctrine/collections/pull/472 --- src/Codeception/Module/Doctrine.php | 2 +- tests/unit/Codeception/Module/Doctrine2Test.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Codeception/Module/Doctrine.php b/src/Codeception/Module/Doctrine.php index cae50f7..74af319 100644 --- a/src/Codeception/Module/Doctrine.php +++ b/src/Codeception/Module/Doctrine.php @@ -1009,7 +1009,7 @@ protected function _buildAssociationQuery(QueryBuilder $qb, string $assoc, strin } elseif ($val instanceof Criteria) { $qb->addCriteria($val); } elseif ($val instanceof Expression) { - $qb->addCriteria(Criteria::create()->where($val)); + $qb->addCriteria(Criteria::create(true)->where($val)); } else { $qb->andWhere(sprintf('%s.%s = ?%s', $alias, $key, $paramIndex)); $qb->setParameter($paramIndex, $val); diff --git a/tests/unit/Codeception/Module/Doctrine2Test.php b/tests/unit/Codeception/Module/Doctrine2Test.php index 2bc9ccb..389a243 100644 --- a/tests/unit/Codeception/Module/Doctrine2Test.php +++ b/tests/unit/Codeception/Module/Doctrine2Test.php @@ -258,17 +258,17 @@ public function testCriteria() { $this->module->haveInRepository(PlainEntity::class, ['name' => 'Test 1']); $this->module->seeInRepository(PlainEntity::class, [ - Criteria::create()->where( + Criteria::create(true)->where( Criteria::expr()->eq('name', 'Test 1') ), ]); $this->module->seeInRepository(PlainEntity::class, [ - Criteria::create()->where( + Criteria::create(true)->where( Criteria::expr()->contains('name', 'est') ), ]); $this->module->seeInRepository(PlainEntity::class, [ - Criteria::create()->where( + Criteria::create(true)->where( Criteria::expr()->in('name', ['Test 1']) ), ]); @@ -303,7 +303,7 @@ public function testOrderBy() 'c', ], array_map($getName, $this->module->grabEntitiesFromRepository(PlainEntity::class, [ - Criteria::create()->orderBy(['name' => 'asc']), + Criteria::create(true)->orderBy(['name' => 'asc']), ])) ); @@ -314,7 +314,7 @@ public function testOrderBy() 'a', ], array_map($getName, $this->module->grabEntitiesFromRepository(PlainEntity::class, [ - Criteria::create()->orderBy(['name' => 'desc']), + Criteria::create(true)->orderBy(['name' => 'desc']), ])) ); }