Code Duplication    Length = 71-71 lines in 2 locations

tests/Query/Selection/SelectAsSpec.php 1 location

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

tests/Query/Selection/SelectHiddenAsSpec.php 1 location

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