Completed
Push — 1.0 ( b7886a...4c0b42 )
by Peter
07:48 queued 11s
created

LikePatternSpec::it_is_a_like_pattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace tests\Happyr\DoctrineSpecification\Operand;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\QueryBuilder;
7
use Happyr\DoctrineSpecification\Operand\LikePattern;
8
use PhpSpec\ObjectBehavior;
9
10
/**
11
 * @mixin LikePattern
12
 */
13
class LikePatternSpec extends ObjectBehavior
14
{
15
    private $value = 'foo';
16
17
    private $format = LikePattern::CONTAINS;
18
19
    public function let()
20
    {
21
        $this->beConstructedWith($this->value, $this->format);
22
    }
23
24
    public function it_is_a_like_pattern()
25
    {
26
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\LikePattern');
27
    }
28
29
    public function it_is_a_operand()
30
    {
31
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\Operand');
32
    }
33
34
    public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameters)
35
    {
36
        $dqlAlias = 'a';
37
38
        $qb->getParameters()->willReturn($parameters);
39
        $parameters->count()->willReturn(10);
40
41
        $qb->setParameter('comparison_10', sprintf($this->format, $this->value))->shouldBeCalled();
42
43
        $this->transform($qb, $dqlAlias)->shouldReturn(':comparison_10');
44
    }
45
}
46