Code Duplication    Length = 50-50 lines in 2 locations

tests/Logic/AndXSpec.php 1 location

@@ 27-76 (lines=50) @@
24
/**
25
 * @mixin AndX
26
 */
27
class AndXSpec extends ObjectBehavior
28
{
29
    public function let(Specification $specificationA, Specification $specificationB)
30
    {
31
        $this->beConstructedWith($specificationA, $specificationB);
32
    }
33
34
    public function it_is_a_specification()
35
    {
36
        $this->shouldHaveType(Specification::class);
37
    }
38
39
    public function it_modifies_all_child_queries(QueryBuilder $queryBuilder, Specification $specificationA, Specification $specificationB)
40
    {
41
        $dqlAlias = 'a';
42
43
        $specificationA->modify($queryBuilder, $dqlAlias)->shouldBeCalled();
44
        $specificationB->modify($queryBuilder, $dqlAlias)->shouldBeCalled();
45
46
        $this->modify($queryBuilder, $dqlAlias);
47
    }
48
49
    public function it_composes_and_child_with_expression(QueryBuilder $qb, Expr $expression, Specification $specificationA, Specification $specificationB, $x, $y)
50
    {
51
        $dqlAlias = 'a';
52
53
        $specificationA->getFilter($qb, $dqlAlias)->willReturn($x);
54
        $specificationB->getFilter($qb, $dqlAlias)->willReturn($y);
55
        $qb->expr()->willReturn($expression);
56
57
        $expression->andX($x, $y)->shouldBeCalled();
58
59
        $this->getFilter($qb, $dqlAlias);
60
    }
61
62
    public function it_supports_expressions(QueryBuilder $qb, Expr $expression, Filter $exprA, Filter $exprB, $x, $y)
63
    {
64
        $this->beConstructedWith($exprA, $exprB);
65
66
        $dqlAlias = 'a';
67
68
        $exprA->getFilter($qb, $dqlAlias)->willReturn($x);
69
        $exprB->getFilter($qb, $dqlAlias)->willReturn($y);
70
        $qb->expr()->willReturn($expression);
71
72
        $expression->andX($x, $y)->shouldBeCalled();
73
74
        $this->getFilter($qb, $dqlAlias);
75
    }
76
}
77

tests/Logic/OrXSpec.php 1 location

@@ 27-76 (lines=50) @@
24
/**
25
 * @mixin OrX
26
 */
27
class OrXSpec extends ObjectBehavior
28
{
29
    public function let(Specification $specificationA, Specification $specificationB)
30
    {
31
        $this->beConstructedWith($specificationA, $specificationB);
32
    }
33
34
    public function it_is_a_specification()
35
    {
36
        $this->shouldHaveType(Specification::class);
37
    }
38
39
    public function it_modifies_all_child_queries(QueryBuilder $queryBuilder, Specification $specificationA, Specification $specificationB)
40
    {
41
        $dqlAlias = 'a';
42
43
        $specificationA->modify($queryBuilder, $dqlAlias)->shouldBeCalled();
44
        $specificationB->modify($queryBuilder, $dqlAlias)->shouldBeCalled();
45
46
        $this->modify($queryBuilder, $dqlAlias);
47
    }
48
49
    public function it_composes_and_child_with_expression(QueryBuilder $qb, Expr $expression, Specification $specificationA, Specification $specificationB, $x, $y)
50
    {
51
        $dqlAlias = 'a';
52
53
        $specificationA->getFilter($qb, $dqlAlias)->willReturn($x);
54
        $specificationB->getFilter($qb, $dqlAlias)->willReturn($y);
55
        $qb->expr()->willReturn($expression);
56
57
        $expression->orX($x, $y)->shouldBeCalled();
58
59
        $this->getFilter($qb, $dqlAlias);
60
    }
61
62
    public function it_supports_expressions(QueryBuilder $qb, Expr $expression, Filter $exprA, Filter $exprB, $x, $y)
63
    {
64
        $this->beConstructedWith($exprA, $exprB);
65
66
        $dqlAlias = 'a';
67
68
        $exprA->getFilter($qb, $dqlAlias)->willReturn($x);
69
        $exprB->getFilter($qb, $dqlAlias)->willReturn($y);
70
        $qb->expr()->willReturn($expression);
71
72
        $expression->orX($x, $y)->shouldBeCalled();
73
74
        $this->getFilter($qb, $dqlAlias);
75
    }
76
}
77