Completed
Push — 2.0 ( 33bb83...14462a )
by Peter
07:18 queued 16s
created

SliceSpec::it_slice_with_zero_index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of the Happyr Doctrine Specification package.
6
 *
7
 * (c) Tobias Nyholm <[email protected]>
8
 *     Kacper Gunia <[email protected]>
9
 *     Peter Gribanov <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace tests\Happyr\DoctrineSpecification\Query;
16
17
use Doctrine\ORM\QueryBuilder;
18
use Happyr\DoctrineSpecification\Query\QueryModifier;
19
use Happyr\DoctrineSpecification\Query\Slice;
20
use PhpSpec\ObjectBehavior;
21
22
/**
23
 * @mixin Slice
24
 */
25
final class SliceSpec extends ObjectBehavior
26
{
27
    /**
28
     * @var int
29
     */
30
    private $sliceSize = 25;
31
32
    public function let(): void
33
    {
34
        $this->beConstructedWith($this->sliceSize, 0);
35
    }
36
37
    public function it_is_a_query_modifier(): void
38
    {
39
        $this->shouldHaveType(QueryModifier::class);
40
    }
41
42
    public function it_slice_with_zero_index(QueryBuilder $qb): void
43
    {
44
        $this->beConstructedWith($this->sliceSize, 0);
45
46
        $qb->setMaxResults($this->sliceSize)->shouldBeCalled();
47
48
        $this->modify($qb, 'a');
49
    }
50
51
    public function it_slice_with_second_index(QueryBuilder $qb): void
52
    {
53
        $sliceNumber = 1;
54
55
        $this->beConstructedWith($this->sliceSize, $sliceNumber);
56
57
        $qb->setMaxResults($this->sliceSize)->shouldBeCalled();
58
        $qb->setFirstResult($this->sliceSize * $sliceNumber)->shouldBeCalled();
59
60
        $this->modify($qb, 'a');
61
    }
62
}
63