Skip to content

Commit 4f0c01f

Browse files
committed
Fix tests
1 parent 293771d commit 4f0c01f

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

tests/Doctrine/Tests/ORM/Functional/ParserResultSerializationTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,44 @@ protected function setUp(): void
3535
*
3636
* @dataProvider provideToSerializedAndBack
3737
*/
38-
public function testSerializeParserResult(Closure $toSerializedAndBack): void
38+
public function testSerializeParserResultForQueryWithSqlWalker(Closure $toSerializedAndBack): void
3939
{
4040
$query = $this->_em
4141
->createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyEmployee u WHERE u.name = :name');
4242

43+
// Use the (legacy) SqlWalker which directly puts an SqlExecutor instance into the parser result
44+
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class);
45+
4346
$parserResult = self::parseQuery($query);
4447
$unserialized = $toSerializedAndBack($parserResult);
4548

4649
$this->assertInstanceOf(ParserResult::class, $unserialized);
4750
$this->assertInstanceOf(ResultSetMapping::class, $unserialized->getResultSetMapping());
4851
$this->assertEquals(['name' => [0]], $unserialized->getParameterMappings());
52+
$this->assertFalse($unserialized->hasSqlFinalizer());
4953
$this->assertInstanceOf(SingleSelectExecutor::class, $unserialized->getSqlExecutor());
5054
}
5155

56+
/**
57+
* @param Closure(ParserResult): ParserResult $toSerializedAndBack
58+
*
59+
* @dataProvider provideToSerializedAndBack
60+
*/
61+
public function testSerializeParserResultForQueryWithSqlOutputWalker(Closure $toSerializedAndBack): void
62+
{
63+
$query = $this->_em
64+
->createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyEmployee u WHERE u.name = :name');
65+
66+
$parserResult = self::parseQuery($query);
67+
$unserialized = $toSerializedAndBack($parserResult);
68+
69+
$this->assertInstanceOf(ParserResult::class, $unserialized);
70+
$this->assertInstanceOf(ResultSetMapping::class, $unserialized->getResultSetMapping());
71+
$this->assertEquals(['name' => [0]], $unserialized->getParameterMappings());
72+
$this->assertTrue($unserialized->hasSqlFinalizer());
73+
$this->assertNotNull($unserialized->getSqlFinalizer());
74+
}
75+
5276
/** @return Generator<string, array{Closure(ParserResult): ParserResult}> */
5377
public function provideToSerializedAndBack(): Generator
5478
{

tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl
8787

8888
public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers(): void
8989
{
90-
$this->connection->expects(self::exactly(3))->method('executeQuery');
90+
$result = $this->getMockBuilder(Result::class)->disableOriginalConstructor()->getMock();
91+
$this->connection->expects(self::exactly(3))->method('executeQuery')->willReturn($result);
9192

9293
$this->createPaginatorWithExtraParametersWithoutOutputWalkers([])->count();
9394
$this->createPaginatorWithExtraParametersWithoutOutputWalkers([[10]])->count();
@@ -96,7 +97,8 @@ public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers()
9697

9798
public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersWhenResultIsNotEmpty(): void
9899
{
99-
$this->connection->expects(self::exactly(1))->method('executeQuery');
100+
$result = $this->getMockBuilder(Result::class)->disableOriginalConstructor()->getMock();
101+
$this->connection->expects(self::exactly(1))->method('executeQuery')->willReturn($result);
100102
$this->expectException(Query\QueryException::class);
101103
$this->expectExceptionMessage('Too many parameters: the query defines 1 parameters and you bound 2');
102104

0 commit comments

Comments
 (0)