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

SelectSpec::it_select_several_fields_as_array()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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