From a6c6f34fe5843d589d43b240c6f119ca3fda2320 Mon Sep 17 00:00:00 2001 From: Gwendolen Lynch Date: Wed, 14 Feb 2024 16:17:27 +0100 Subject: [PATCH] Parser is final in v3 and can't be mocked --- .../BaseComparisonFunctionTestCase.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php index cb617b76..382b0867 100644 --- a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php +++ b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php @@ -4,7 +4,9 @@ namespace Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\Lexer; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Query; use Doctrine\ORM\Query\Parser; use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseComparisonFunction; @@ -20,14 +22,16 @@ public function throws_an_exception_when_lexer_is_not_populated_with_a_lookahead $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('The parser\'s "lookahead" property is not populated with a type'); - $lexer = $this->createMock(Lexer::class); - $lexer->lookahead = null; + $em = $this->createMock(EntityManager::class); + $em->expects($this->any()) + ->method('getConfiguration') + ->willReturn(new Configuration()); - $parser = $this->createMock(Parser::class); - $parser - ->expects($this->once()) - ->method('getLexer') - ->willReturn($lexer); + $query = new Query($em); + $query->setDQL('TRUE'); + + $parser = new Parser($query); + $parser->getLexer()->moveNext(); $this->createFixture()->feedParserWithNodes($parser); }