LikePatternSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_like_pattern() 0 4 1
A it_is_a_operand() 0 4 1
A it_is_transformable() 0 11 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\Operand;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\ORM\QueryBuilder;
18
use Happyr\DoctrineSpecification\Operand\LikePattern;
19
use Happyr\DoctrineSpecification\Operand\Operand;
20
use PhpSpec\ObjectBehavior;
21
22
/**
23
 * @mixin LikePattern
24
 */
25
class LikePatternSpec extends ObjectBehavior
26
{
27
    private $value = 'foo';
28
29
    private $format = LikePattern::CONTAINS;
30
31
    public function let()
32
    {
33
        $this->beConstructedWith($this->value, $this->format);
34
    }
35
36
    public function it_is_a_like_pattern()
37
    {
38
        $this->shouldBeAnInstanceOf(LikePattern::class);
39
    }
40
41
    public function it_is_a_operand()
42
    {
43
        $this->shouldBeAnInstanceOf(Operand::class);
44
    }
45
46
    public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameters)
47
    {
48
        $dqlAlias = 'a';
49
50
        $qb->getParameters()->willReturn($parameters);
51
        $parameters->count()->willReturn(10);
52
53
        $qb->setParameter('comparison_10', sprintf($this->format, $this->value))->shouldBeCalled();
54
55
        $this->transform($qb, $dqlAlias)->shouldReturn(':comparison_10');
56
    }
57
}
58