diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index 42a6a8b67ab..ca77a02a68f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -421,6 +421,39 @@ public function testBitAndComparison(): void self::assertEquals($result[3][0]['salary'] / 100000 & 2, $result[3]['salary_bit_and']); } + public function testInArithmeticExpression1(): void + { + $dql = <<_em->createQuery($dql)->getArrayResult(); + + self::assertCount(2, $result); + self::assertEquals('Roman B.', $result[0]['name']); + self::assertEquals('Benjamin E.', $result[1]['name']); + } + + public function testInArithmeticExpression2(): void + { + $this->_em->getConfiguration()->addCustomStringFunction('FOO', static function ($funcName) { + return new NoOp($funcName); // See Doctrine/Tests/ORM/Functional/CustomFunctionsTest + }); + + $dql = <<_em->createQuery($dql)->getArrayResult(); + + self::assertCount(1, $result); + self::assertEquals('Jonathan W.', $result[0]['name']); + } + protected function generateFixture(): void { $manager1 = new CompanyManager(); diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 110c93d774e..a970dfe840c 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -643,20 +643,17 @@ public function testInvalidInExpressionWithSingleValuedAssociationPathExpression ); } - public function testCustomFunctionWithinInExpression() : void + public function testInExpressionWithArithmeticExpression(): void { $this->entityManager->getConfiguration()->addCustomStringFunction('FOO', MyAbsFunction::class); + $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.username IN (FOO('Lo'), 'Lo', :name)", - <<<'SQL' -SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username IN (ABS('Lo'), 'Lo', ?) -SQL + "SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username IN (ABS('Lo'), 'Lo', ?)" ); $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.id IN (1+1)', - <<<'SQL' -SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.id IN (1 + 1) -SQL + 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.id IN (1 + 1)', + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.id IN (1 + 1)' ); }