Completed
Push — 2.0 ( 6b5a44...d543e3 )
by Peter
06:53 queued 19s
created

SelectSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_select() 0 4 1
A it_is_a_specification() 0 4 1
A it_select_single_filed() 0 5 1
A it_select_several_fields() 0 6 1
A it_select_operand() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of the Happyr Doctrine Specification package.
6
 *
7
 * (c) Tobias Nyholm <[email protected]>
8
 *     Kacper Gunia <[email protected]>
9
 *     Peter Gribanov <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace tests\Happyr\DoctrineSpecification\Query;
16
17
use Doctrine\ORM\QueryBuilder;
18
use Happyr\DoctrineSpecification\Operand\Field;
19
use Happyr\DoctrineSpecification\Query\QueryModifier;
20
use Happyr\DoctrineSpecification\Query\Select;
21
use PhpSpec\ObjectBehavior;
22
23
/**
24
 * @mixin Select
25
 */
26
class SelectSpec extends ObjectBehavior
27
{
28
    public function let()
29
    {
30
        $this->beConstructedWith('foo');
31
    }
32
33
    public function it_is_a_select()
34
    {
35
        $this->shouldBeAnInstanceOf(Select::class);
36
    }
37
38
    public function it_is_a_specification()
39
    {
40
        $this->shouldHaveType(QueryModifier::class);
41
    }
42
43
    public function it_select_single_filed(QueryBuilder $qb)
44
    {
45
        $qb->select(['a.foo'])->shouldBeCalled();
46
        $this->modify($qb, 'a');
47
    }
48
49
    public function it_select_several_fields(QueryBuilder $qb)
50
    {
51
        $this->beConstructedWith('foo', 'bar');
52
        $qb->select(['b.foo', 'b.bar'])->shouldBeCalled();
53
        $this->modify($qb, 'b');
54
    }
55
56
    public function it_select_operand(QueryBuilder $qb)
57
    {
58
        $this->beConstructedWith('foo', new Field('bar'));
59
        $qb->select(['b.foo', 'b.bar'])->shouldBeCalled();
60
        $this->modify($qb, 'b');
61
    }
62
}
63