Skip to content

Commit 3e34b8e

Browse files
committed
Add a test to reproduce the issue
1 parent 7d950ab commit 3e34b8e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\ORM\Functional\Ticket;
6+
7+
use Doctrine\ORM\Tools\Pagination\Paginator;
8+
use Doctrine\Tests\Models\CMS\CmsArticle;
9+
use Doctrine\Tests\OrmFunctionalTestCase;
10+
11+
final class GH12183Test extends OrmFunctionalTestCase
12+
{
13+
protected function setUp(): void
14+
{
15+
$this->useModelSet('cms');
16+
17+
parent::setUp();
18+
19+
$article = new CmsArticle();
20+
21+
$article->topic = 'Loomings';
22+
$article->text = 'Call me Ishmael.';
23+
24+
$this->_em->persist($article);
25+
$this->_em->flush();
26+
$this->_em->clear();
27+
}
28+
29+
public function testPaginatorCountWithOutputWalkerAfterQueryHasBeenExecuted(): void
30+
{
31+
$query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a');
32+
33+
// Paginator::count is right when the query has not yet been executed
34+
$paginator = new Paginator($query);
35+
$paginator->setUseOutputWalkers(false);
36+
self::assertSame(1, $paginator->count());
37+
38+
// Execute the query
39+
$result = $query->getResult();
40+
self::assertCount(1, $result);
41+
42+
$paginator = new Paginator($query);
43+
$paginator->setUseOutputWalkers(false);
44+
self::assertSame(1, $paginator->count());
45+
}
46+
}

0 commit comments

Comments
 (0)