|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Logging\DebugStack; |
|
8
|
|
|
use Doctrine\ORM\Tools\Pagination\Paginator; |
|
9
|
|
|
use Doctrine\Tests\Models\CMS\CmsArticle; |
|
10
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @group GH7829 |
|
14
|
|
|
*/ |
|
15
|
|
|
final class GH7829Test extends OrmFunctionalTestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var DebugStack */ |
|
18
|
|
|
private $logger; |
|
19
|
|
|
|
|
20
|
|
|
protected function setUp() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->useModelSet('cms'); |
|
23
|
|
|
parent::setUp(); |
|
24
|
|
|
|
|
25
|
|
|
$article = new CmsArticle(); |
|
26
|
|
|
|
|
27
|
|
|
$article->topic = 'Skip Limit Subquery'; |
|
28
|
|
|
$article->text = 'Skip Limit Subquery if not required.'; |
|
29
|
|
|
|
|
30
|
|
|
$this->_em->persist($article); |
|
31
|
|
|
$this->_em->flush(); |
|
32
|
|
|
$this->_em->clear(); |
|
33
|
|
|
|
|
34
|
|
|
$this->_em->getConnection()->getConfiguration()->setSQLLogger($this->logger = new DebugStack()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function testPaginatorWithLimitSubquery() : void |
|
38
|
|
|
{ |
|
39
|
|
|
$query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a'); |
|
40
|
|
|
$query->setMaxResults(1); |
|
41
|
|
|
|
|
42
|
|
|
$paginator = new Paginator($query, true); |
|
43
|
|
|
$paginator->setUseOutputWalkers(false); |
|
44
|
|
|
|
|
45
|
|
|
$paginator->count(); |
|
46
|
|
|
$paginator->getIterator(); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertCount(3, $this->logger->queries); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testPaginatorWithLimitSubquerySkipped() : void |
|
52
|
|
|
{ |
|
53
|
|
|
$query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a'); |
|
54
|
|
|
|
|
55
|
|
|
$paginator = new Paginator($query, true); |
|
56
|
|
|
$paginator->setUseOutputWalkers(false); |
|
57
|
|
|
|
|
58
|
|
|
$paginator->count(); |
|
59
|
|
|
$paginator->getIterator(); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertCount(2, $this->logger->queries); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|