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

LikeSpec::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\Spec;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\QueryBuilder;
7
use Happyr\DoctrineSpecification\Filter\Like;
8
use PhpSpec\ObjectBehavior;
9
10
class LikeSpec extends ObjectBehavior
11
{
12
    private $field = 'foo';
13
14
    private $value = 'bar';
15
16
    public function let()
17
    {
18
        $this->beConstructedWith($this->field, $this->value, Like::CONTAINS, 'dqlAlias');
19
    }
20
21
    public function it_is_a_specification()
22
    {
23
        $this->shouldHaveType('Happyr\DoctrineSpecification\Specification\Specification');
24
    }
25
26 View Code Duplication
    public function it_surrounds_with_wildcards_when_using_contains(QueryBuilder $qb, ArrayCollection $parameters)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $this->beConstructedWith($this->field, $this->value, Like::CONTAINS, 'dqlAlias');
29
        $qb->getParameters()->willReturn($parameters);
30
        $parameters->count()->willReturn(1);
31
32
        $qb->setParameter('comparison_1', '%bar%')->shouldBeCalled();
33
34
        $this->match($qb, null);
35
    }
36
37 View Code Duplication
    public function it_starts_with_wildcard_when_using_ends_with(QueryBuilder $qb, ArrayCollection $parameters)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $this->beConstructedWith($this->field, $this->value, Like::ENDS_WITH, 'dqlAlias');
40
        $qb->getParameters()->willReturn($parameters);
41
        $parameters->count()->willReturn(1);
42
43
        $qb->setParameter('comparison_1', '%bar')->shouldBeCalled();
44
45
        $this->match($qb, null);
46
    }
47
48 View Code Duplication
    public function it_ends_with_wildcard_when_using_starts_with(QueryBuilder $qb, ArrayCollection $parameters)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $this->beConstructedWith($this->field, $this->value, Like::STARTS_WITH, 'dqlAlias');
51
        $qb->getParameters()->willReturn($parameters);
52
        $parameters->count()->willReturn(1);
53
54
        $qb->setParameter('comparison_1', 'bar%')->shouldBeCalled();
55
56
        $this->match($qb, null);
57
    }
58
}
59