Code Duplication    Length = 39-39 lines in 2 locations

tests/Filter/IsNotNullSpec.php 1 location

@@ 13-51 (lines=39) @@
10
/**
11
 * @mixin IsNotNull
12
 */
13
class IsNotNullSpec extends ObjectBehavior
14
{
15
    private $field = 'foobar';
16
17
    private $dqlAlias = 'a';
18
19
    public function let()
20
    {
21
        $this->beConstructedWith($this->field, $this->dqlAlias);
22
    }
23
24
    public function it_is_an_expression()
25
    {
26
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Filter\Filter');
27
    }
28
29
    /**
30
     * returns expression func object.
31
     */
32
    public function it_calls_not_null(QueryBuilder $qb, Expr $expr)
33
    {
34
        $expression = 'a.foobar is not null';
35
36
        $qb->expr()->willReturn($expr);
37
        $expr->isNotNull(sprintf('%s.%s', $this->dqlAlias, $this->field))->willReturn($expression);
38
39
        $this->getFilter($qb, null)->shouldReturn($expression);
40
    }
41
42
    public function it_uses_dql_alias_if_passed(QueryBuilder $qb, Expr $expr)
43
    {
44
        $dqlAlias = 'x';
45
        $this->beConstructedWith($this->field, null);
46
        $qb->expr()->willReturn($expr);
47
48
        $expr->isNotNull(sprintf('%s.%s', $dqlAlias, $this->field))->shouldBeCalled();
49
        $this->getFilter($qb, $dqlAlias);
50
    }
51
}
52

tests/Filter/IsNullSpec.php 1 location

@@ 13-51 (lines=39) @@
10
/**
11
 * @mixin IsNull
12
 */
13
class IsNullSpec extends ObjectBehavior
14
{
15
    private $field = 'foobar';
16
17
    private $dqlAlias = 'a';
18
19
    public function let()
20
    {
21
        $this->beConstructedWith($this->field, $this->dqlAlias);
22
    }
23
24
    public function it_is_an_expression()
25
    {
26
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Filter\Filter');
27
    }
28
29
    /**
30
     * returns expression func object.
31
     */
32
    public function it_calls_null(QueryBuilder $qb, Expr $expr)
33
    {
34
        $expression = 'a.foobar is null';
35
36
        $qb->expr()->willReturn($expr);
37
        $expr->isNull(sprintf('%s.%s', $this->dqlAlias, $this->field))->willReturn($expression);
38
39
        $this->getFilter($qb, 'b')->shouldReturn($expression);
40
    }
41
42
    public function it_uses_dql_alias_if_passed(QueryBuilder $qb, Expr $expr)
43
    {
44
        $dqlAlias = 'x';
45
        $this->beConstructedWith($this->field, null);
46
        $qb->expr()->willReturn($expr);
47
48
        $expr->isNull(sprintf('%s.%s', $dqlAlias, $this->field))->shouldBeCalled();
49
        $this->getFilter($qb, $dqlAlias);
50
    }
51
}
52