Skip to content

Commit

Permalink
Parser is final in v3 and can't be mocked
Browse files Browse the repository at this point in the history
  • Loading branch information
GwendolenLynch committed Feb 14, 2024
1 parent 837275e commit a6c6f34
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

0 comments on commit a6c6f34

Please sign in to comment.