Code Duplication    Length = 71-71 lines in 2 locations

tests/Query/Selection/SelectAsSpec.php 1 location

@@ 17-87 (lines=71) @@
14
/**
15
 * @mixin SelectAs
16
 */
17
class SelectAsSpec extends ObjectBehavior
18
{
19
    private $field = 'foo';
20
21
    private $alias = 'bar';
22
23
    public function let()
24
    {
25
        $this->beConstructedWith($this->field, $this->alias);
26
    }
27
28
    public function it_is_a_select_as()
29
    {
30
        $this->shouldBeAnInstanceOf(SelectAs::class);
31
    }
32
33
    public function it_is_a_selection()
34
    {
35
        $this->shouldBeAnInstanceOf(Selection::class);
36
    }
37
38
    public function it_is_transformable(QueryBuilder $qb)
39
    {
40
        $dqlAlias = 'a';
41
        $expression = '(a.foo) AS bar';
42
43
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
44
    }
45
46
    public function it_is_transformable_field(QueryBuilder $qb)
47
    {
48
        $dqlAlias = 'a';
49
        $expression = '(a.foo) AS bar';
50
        $field = new Field('foo');
51
52
        $this->beConstructedWith($field, $this->alias);
53
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
54
    }
55
56
    public function it_is_transformable_value(QueryBuilder $qb, ArrayCollection $parameters)
57
    {
58
        $dqlAlias = 'a';
59
        $expression = '(:comparison_10) AS bar';
60
        $value = new Value('foo');
61
62
        $this->beConstructedWith($value, $this->alias);
63
64
        $qb->getParameters()->willReturn($parameters);
65
        $parameters->count()->willReturn(10);
66
67
        $qb->setParameter('comparison_10', 'foo', null)->shouldBeCalled();
68
69
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
70
    }
71
72
    public function it_is_transformable_filter(QueryBuilder $qb, ArrayCollection $parameters)
73
    {
74
        $dqlAlias = 'a';
75
        $expression = '(a.foo = :comparison_10) AS bar';
76
        $filter = new Equals('foo', 'bar');
77
78
        $this->beConstructedWith($filter, $this->alias);
79
80
        $qb->getParameters()->willReturn($parameters);
81
        $parameters->count()->willReturn(10);
82
83
        $qb->setParameter('comparison_10', 'bar', null)->shouldBeCalled();
84
85
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
86
    }
87
}
88

tests/Query/Selection/SelectHiddenAsSpec.php 1 location

@@ 17-87 (lines=71) @@
14
/**
15
 * @mixin SelectHiddenAs
16
 */
17
class SelectHiddenAsSpec extends ObjectBehavior
18
{
19
    private $field = 'foo';
20
21
    private $alias = 'bar';
22
23
    public function let()
24
    {
25
        $this->beConstructedWith($this->field, $this->alias);
26
    }
27
28
    public function it_is_a_select_as()
29
    {
30
        $this->shouldBeAnInstanceOf(SelectHiddenAs::class);
31
    }
32
33
    public function it_is_a_selection()
34
    {
35
        $this->shouldBeAnInstanceOf(Selection::class);
36
    }
37
38
    public function it_is_transformable(QueryBuilder $qb)
39
    {
40
        $dqlAlias = 'a';
41
        $expression = '(a.foo) AS HIDDEN bar';
42
43
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
44
    }
45
46
    public function it_is_transformable_field(QueryBuilder $qb)
47
    {
48
        $dqlAlias = 'a';
49
        $expression = '(a.foo) AS HIDDEN bar';
50
        $field = new Field('foo');
51
52
        $this->beConstructedWith($field, $this->alias);
53
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
54
    }
55
56
    public function it_is_transformable_value(QueryBuilder $qb, ArrayCollection $parameters)
57
    {
58
        $dqlAlias = 'a';
59
        $expression = '(:comparison_10) AS HIDDEN bar';
60
        $value = new Value('foo');
61
62
        $this->beConstructedWith($value, $this->alias);
63
64
        $qb->getParameters()->willReturn($parameters);
65
        $parameters->count()->willReturn(10);
66
67
        $qb->setParameter('comparison_10', 'foo', null)->shouldBeCalled();
68
69
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
70
    }
71
72
    public function it_is_transformable_filter(QueryBuilder $qb, ArrayCollection $parameters)
73
    {
74
        $dqlAlias = 'a';
75
        $expression = '(a.foo = :comparison_10) AS HIDDEN bar';
76
        $filter = new Equals('foo', 'bar');
77
78
        $this->beConstructedWith($filter, $this->alias);
79
80
        $qb->getParameters()->willReturn($parameters);
81
        $parameters->count()->willReturn(10);
82
83
        $qb->setParameter('comparison_10', 'bar', null)->shouldBeCalled();
84
85
        $this->transform($qb, $dqlAlias)->shouldReturn($expression);
86
    }
87
}
88