Code Duplication    Length = 71-71 lines in 2 locations

tests/Query/Selection/SelectAsSpec.php 1 location

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

tests/Query/Selection/SelectHiddenAsSpec.php 1 location

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