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

InSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_an_expression() 0 4 1
A it_returns_expression_func_object() 0 13 1
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