Completed
Push — 1.0 ( 75b22b...f155d9 )
by Peter
15:56 queued 05:56
created

AddSelectSpec::it_is_a_add_select()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace tests\Happyr\DoctrineSpecification\Query;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Happyr\DoctrineSpecification\Operand\Field;
7
use Happyr\DoctrineSpecification\Query\AddSelect;
8
use PhpSpec\ObjectBehavior;
9
10
/**
11
 * @mixin AddSelect
12
 */
13 View Code Duplication
class AddSelectSpec extends ObjectBehavior
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    public function let()
16
    {
17
        $this->beConstructedWith('foo');
18
    }
19
20
    public function it_is_a_add_select()
21
    {
22
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Query\AddSelect');
23
    }
24
25
    public function it_is_a_specification()
26
    {
27
        $this->shouldHaveType('Happyr\DoctrineSpecification\Query\QueryModifier');
28
    }
29
30
    public function it_add_select_single_filed(QueryBuilder $qb)
31
    {
32
        $qb->addSelect(['a.foo'])->shouldBeCalled();
33
        $this->modify($qb, 'a');
34
    }
35
36
    public function it_add_select_several_fields(QueryBuilder $qb)
37
    {
38
        $this->beConstructedWith('foo', 'bar');
39
        $qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled();
40
        $this->modify($qb, 'b');
41
    }
42
43
    public function it_add_select_several_fields_as_array(QueryBuilder $qb)
44
    {
45
        $this->beConstructedWith(['foo', 'bar']);
46
        $qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled();
47
        $this->modify($qb, 'b');
48
    }
49
50
    public function it_add_select_operand(QueryBuilder $qb)
51
    {
52
        $this->beConstructedWith('foo', new Field('bar'));
53
        $qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled();
54
        $this->modify($qb, 'b');
55
    }
56
}
57