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

SliceSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_specification() 0 4 1
A it_slice_with_zero_index() 0 8 1
A it_slice_with_second_index() 0 11 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