FieldSpec::it_is_change_dql_alias()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace tests\Happyr\DoctrineSpecification\Operand;
15
16
use Doctrine\ORM\QueryBuilder;
17
use Happyr\DoctrineSpecification\Operand\Field;
18
use Happyr\DoctrineSpecification\Operand\Operand;
19
use PhpSpec\ObjectBehavior;
20
21
/**
22
 * @mixin Field
23
 */
24
class FieldSpec extends ObjectBehavior
25
{
26
    private $fieldName = 'foo';
27
28
    public function let()
29
    {
30
        $this->beConstructedWith($this->fieldName);
31
    }
32
33
    public function it_is_a_field()
34
    {
35
        $this->shouldBeAnInstanceOf(Field::class);
36
    }
37
38
    public function it_is_a_operand()
39
    {
40
        $this->shouldBeAnInstanceOf(Operand::class);
41
    }
42
43
    public function it_is_transformable(QueryBuilder $qb)
44
    {
45
        $dqlAlias = 'a';
46
        $expression = 'a.foo';
47
48
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
49
    }
50
51
    public function it_is_change_dql_alias(QueryBuilder $qb)
52
    {
53
        $dqlAlias = 'a';
54
        $expression = 'b.foo';
55
56
        $this->beConstructedWith($this->fieldName, 'b');
57
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
58
    }
59
}
60