Completed
Push — 2.0 ( 33bb83...14462a )
by Peter
07:18 queued 16s
created

AddSelectSpec::let()   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
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\AddSelect;
20
use Happyr\DoctrineSpecification\Query\QueryModifier;
21
use PhpSpec\ObjectBehavior;
22
23
/**
24
 * @mixin AddSelect
25
 */
26 View Code Duplication
final 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...
27
{
28
    public function let(): void
29
    {
30
        $this->beConstructedWith('foo');
31
    }
32
33
    public function it_is_a_add_select(): void
34
    {
35
        $this->shouldBeAnInstanceOf(AddSelect::class);
36
    }
37
38
    public function it_is_a_query_modifier(): void
39
    {
40
        $this->shouldHaveType(QueryModifier::class);
41
    }
42
43
    public function it_add_select_single_filed(QueryBuilder $qb): void
44
    {
45
        $qb->addSelect(['a.foo'])->shouldBeCalled();
46
        $this->modify($qb, 'a');
47
    }
48
49
    public function it_add_select_several_fields(QueryBuilder $qb): void
50
    {
51
        $this->beConstructedWith('foo', 'bar');
52
        $qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled();
53
        $this->modify($qb, 'b');
54
    }
55
56
    public function it_add_select_operand(QueryBuilder $qb): void
57
    {
58
        $this->beConstructedWith('foo', new Field('bar'));
59
        $qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled();
60
        $this->modify($qb, 'b');
61
    }
62
}
63