InSpec   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

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
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace tests\Happyr\DoctrineSpecification\Filter;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\ORM\Query\Expr;
18
use Doctrine\ORM\QueryBuilder;
19
use Happyr\DoctrineSpecification\Filter\Filter;
20
use Happyr\DoctrineSpecification\Filter\In;
21
use PhpSpec\ObjectBehavior;
22
23
/**
24
 * @mixin In
25
 */
26
class InSpec extends ObjectBehavior
27
{
28
    private $field = 'foobar';
29
30
    private $value = ['bar', 'baz'];
31
32
    public function let()
33
    {
34
        $this->beConstructedWith($this->field, $this->value, 'a');
35
    }
36
37
    public function it_is_an_expression()
38
    {
39
        $this->shouldBeAnInstanceOf(Filter::class);
40
    }
41
42
    public function it_returns_expression_func_object(QueryBuilder $qb, ArrayCollection $parameters, Expr $expr)
43
    {
44
        $dqlAlias = 'a';
45
        $qb->expr()->willReturn($expr);
46
        $expr->in(sprintf('%s.%s', $dqlAlias, $this->field), ':comparison_10')->shouldBeCalled();
47
48
        $qb->getParameters()->willReturn($parameters);
49
        $parameters->count()->willReturn(10);
50
51
        $qb->setParameter('comparison_10', $this->value, null)->shouldBeCalled();
52
53
        $this->getFilter($qb, null);
54
    }
55
}
56