Completed
Push — master ( 0bc2a3...83b98a )
by Peter
05:59 queued 10s
created

IndexBySpec::it_indexes_with_default_dql_alias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace tests\Happyr\DoctrineSpecification\Query;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Happyr\DoctrineSpecification\Query\IndexBy;
7
use PhpSpec\ObjectBehavior;
8
9
/**
10
 * @mixin IndexBy
11
 */
12
class IndexBySpec extends ObjectBehavior
13
{
14
    private $field = 'the_field';
15
16
    private $alias = 'f';
17
18
    public function let()
19
    {
20
        $this->beConstructedWith($this->field, $this->alias);
21
    }
22
23
    public function it_is_a_result_modifier()
24
    {
25
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Query\QueryModifier');
26
    }
27
28
    public function it_indexes_with_default_dql_alias(QueryBuilder $qb)
29
    {
30
        $this->beConstructedWith('something', 'x');
31
        $qb->indexBy('x', 'x.something')->shouldBeCalled();
32
        $this->modify($qb, 'a');
33
    }
34
35
    public function it_uses_local_alias_if_global_was_not_set(QueryBuilder $qb)
36
    {
37
        $this->beConstructedWith('thing');
38
        $qb->indexBy('b', 'b.thing')->shouldBeCalled();
39
        $this->modify($qb, 'b');
40
    }
41
}
42