Completed
Push — master ( df6e71...654afb )
by Tobias
08:15
created

SliceSpec::it_slice_with_second_index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
namespace tests\Happyr\DoctrineSpecification\Query;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Happyr\DoctrineSpecification\Query\Slice;
7
use PhpSpec\ObjectBehavior;
8
9
/**
10
 * @mixin Slice
11
 */
12
class SliceSpec extends ObjectBehavior
13
{
14
    /**
15
     * @var int
16
     */
17
    private $sliceSize = 25;
18
19
    public function let()
20
    {
21
        $this->beConstructedWith($this->sliceSize, 0);
22
    }
23
24
    public function it_is_a_specification()
25
    {
26
        $this->shouldHaveType('Happyr\DoctrineSpecification\Query\QueryModifier');
27
    }
28
29
    public function it_slice_with_zero_index(QueryBuilder $qb)
30
    {
31
        $this->beConstructedWith($this->sliceSize, 0);
32
33
        $qb->setMaxResults($this->sliceSize)->shouldBeCalled();
34
35
        $this->modify($qb, 'a');
36
    }
37
38
    public function it_slice_with_second_index(QueryBuilder $qb)
39
    {
40
        $sliceNumber = 1;
41
42
        $this->beConstructedWith($this->sliceSize, $sliceNumber);
43
44
        $qb->setMaxResults($this->sliceSize)->shouldBeCalled();
45
        $qb->setFirstResult($this->sliceSize * $sliceNumber)->shouldBeCalled();
46
47
        $this->modify($qb, 'a');
48
    }
49
}
50