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

InSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
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\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Query\Expr;
7
use Doctrine\ORM\QueryBuilder;
8
use Happyr\DoctrineSpecification\Filter\In;
9
use PhpSpec\ObjectBehavior;
10
11
/**
12
 * @mixin In
13
 */
14
class InSpec extends ObjectBehavior
15
{
16
    private $field = 'foobar';
17
18
    private $value = array('bar', 'baz');
19
20
    public function let()
21
    {
22
        $this->beConstructedWith($this->field, $this->value, 'a');
23
    }
24
25
    public function it_is_an_expression()
26
    {
27
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Filter\Filter');
28
    }
29
30
    public function it_returns_expression_func_object(QueryBuilder $qb, ArrayCollection $parameters, Expr $expr)
31
    {
32
        $dqlAlias = 'a';
33
        $qb->expr()->willReturn($expr);
34
        $expr->in(sprintf('%s.%s', $dqlAlias, $this->field), ':in_10')->shouldBeCalled();
35
36
        $qb->getParameters()->willReturn($parameters);
37
        $parameters->count()->willReturn(10);
38
39
        $qb->setParameter('in_10', $this->value)->shouldBeCalled();
40
41
        $this->getFilter($qb, null);
42
    }
43
}
44