Code Duplication    Length = 39-39 lines in 2 locations

tests/Filter/IsNotNullSpec.php 1 location

@@ 25-63 (lines=39) @@
22
/**
23
 * @mixin IsNotNull
24
 */
25
class IsNotNullSpec extends ObjectBehavior
26
{
27
    private $field = 'foobar';
28
29
    private $dqlAlias = 'a';
30
31
    public function let()
32
    {
33
        $this->beConstructedWith($this->field, $this->dqlAlias);
34
    }
35
36
    public function it_is_an_expression()
37
    {
38
        $this->shouldBeAnInstanceOf(Filter::class);
39
    }
40
41
    /**
42
     * returns expression func object.
43
     */
44
    public function it_calls_not_null(QueryBuilder $qb, Expr $expr)
45
    {
46
        $expression = 'a.foobar is not null';
47
48
        $qb->expr()->willReturn($expr);
49
        $expr->isNotNull(sprintf('%s.%s', $this->dqlAlias, $this->field))->willReturn($expression);
50
51
        $this->getFilter($qb, null)->shouldReturn($expression);
52
    }
53
54
    public function it_uses_dql_alias_if_passed(QueryBuilder $qb, Expr $expr)
55
    {
56
        $dqlAlias = 'x';
57
        $this->beConstructedWith($this->field, null);
58
        $qb->expr()->willReturn($expr);
59
60
        $expr->isNotNull(sprintf('%s.%s', $dqlAlias, $this->field))->shouldBeCalled();
61
        $this->getFilter($qb, $dqlAlias);
62
    }
63
}
64

tests/Filter/IsNullSpec.php 1 location

@@ 25-63 (lines=39) @@
22
/**
23
 * @mixin IsNull
24
 */
25
class IsNullSpec extends ObjectBehavior
26
{
27
    private $field = 'foobar';
28
29
    private $dqlAlias = 'a';
30
31
    public function let()
32
    {
33
        $this->beConstructedWith($this->field, $this->dqlAlias);
34
    }
35
36
    public function it_is_an_expression()
37
    {
38
        $this->shouldBeAnInstanceOf(Filter::class);
39
    }
40
41
    /**
42
     * returns expression func object.
43
     */
44
    public function it_calls_null(QueryBuilder $qb, Expr $expr)
45
    {
46
        $expression = 'a.foobar is null';
47
48
        $qb->expr()->willReturn($expr);
49
        $expr->isNull(sprintf('%s.%s', $this->dqlAlias, $this->field))->willReturn($expression);
50
51
        $this->getFilter($qb, 'b')->shouldReturn($expression);
52
    }
53
54
    public function it_uses_dql_alias_if_passed(QueryBuilder $qb, Expr $expr)
55
    {
56
        $dqlAlias = 'x';
57
        $this->beConstructedWith($this->field, null);
58
        $qb->expr()->willReturn($expr);
59
60
        $expr->isNull(sprintf('%s.%s', $dqlAlias, $this->field))->shouldBeCalled();
61
        $this->getFilter($qb, $dqlAlias);
62
    }
63
}
64