SliceSpec   A
last analyzed

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