Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/Codeception/Module/Doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions tests/unit/Codeception/Module/Doctrine2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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'])
),
]);
Expand Down Expand Up @@ -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']),
]))
);

Expand All @@ -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']),
]))
);
}
Expand Down