Completed
Pull Request — 2.7 (#7863)
by
unknown
08:47
created

GH7829Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9666
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
class GH7829Test extends OrmFunctionalTestCase
16
{
17
    /**
18
     * @var DebugStack
19
     */
20
    protected $logger;
21
22
    protected function setUp()
23
    {
24
        $this->useModelSet('cms');
25
        parent::setUp();
26
27
        $article = new CmsArticle();
28
29
        $article->topic = 'Skip Limit Subquery';
30
        $article->text  = 'Skip Limit Subquery if not required.';
31
32
        $this->_em->persist($article);
33
        $this->_em->flush();
34
        $this->_em->clear();
35
36
        $this->_em->getConnection()->getConfiguration()->setSQLLogger($this->logger = new DebugStack());
37
    }
38
39
    public function testPaginatorWithLimitSubquery() : void
40
    {
41
        $query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a');
42
        $query->setMaxResults(1);
43
44
        $paginator = new Paginator($query, true);
45
        $paginator->setUseOutputWalkers(false);
46
47
        $paginator->count();
48
        $paginator->getIterator();
49
50
        $this->assertCount(3, $this->logger->queries);
51
    }
52
53
    public function testPaginatorWithLimitSubquerySkipped() : void
54
    {
55
        $query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a');
56
57
        $paginator = new Paginator($query, true);
58
        $paginator->setUseOutputWalkers(false);
59
60
        $paginator->count();
61
        $paginator->getIterator();
62
63
        $this->assertCount(2, $this->logger->queries);
64
    }
65
}
66