Completed
Push — patch-meta ( 5bd3e7 )
by Tobias
08:29
created

IsNotNullSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace tests\Happyr\DoctrineSpecification\Filter;
4
5
use Doctrine\ORM\Query\Expr;
6
use Doctrine\ORM\QueryBuilder;
7
use Happyr\DoctrineSpecification\Filter\IsNotNull;
8
use PhpSpec\ObjectBehavior;
9
10
/**
11
 * @mixin IsNotNull
12
 */
13 View Code Duplication
class IsNotNullSpec extends ObjectBehavior
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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