These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Spec; |
||
15 | |||
16 | use Doctrine\Common\Collections\ArrayCollection; |
||
17 | use Doctrine\ORM\QueryBuilder; |
||
18 | use Happyr\DoctrineSpecification\Filter\Like; |
||
19 | use Happyr\DoctrineSpecification\Specification\Specification; |
||
20 | use PhpSpec\ObjectBehavior; |
||
21 | |||
22 | class LikeSpec extends ObjectBehavior |
||
23 | { |
||
24 | private $field = 'foo'; |
||
25 | |||
26 | private $value = 'bar'; |
||
27 | |||
28 | public function let() |
||
29 | { |
||
30 | $this->beConstructedWith($this->field, $this->value, Like::CONTAINS, 'dqlAlias'); |
||
31 | } |
||
32 | |||
33 | public function it_is_a_specification() |
||
34 | { |
||
35 | $this->shouldHaveType(Specification::class); |
||
36 | } |
||
37 | |||
38 | View Code Duplication | public function it_surrounds_with_wildcards_when_using_contains(QueryBuilder $qb, ArrayCollection $parameters) |
|
0 ignored issues
–
show
|
|||
39 | { |
||
40 | $this->beConstructedWith($this->field, $this->value, Like::CONTAINS, 'dqlAlias'); |
||
41 | $qb->getParameters()->willReturn($parameters); |
||
42 | $parameters->count()->willReturn(1); |
||
43 | |||
44 | $qb->setParameter('comparison_1', '%bar%')->shouldBeCalled(); |
||
45 | |||
46 | $this->match($qb, null); |
||
47 | } |
||
48 | |||
49 | View Code Duplication | public function it_starts_with_wildcard_when_using_ends_with(QueryBuilder $qb, ArrayCollection $parameters) |
|
0 ignored issues
–
show
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...
|
|||
50 | { |
||
51 | $this->beConstructedWith($this->field, $this->value, Like::ENDS_WITH, 'dqlAlias'); |
||
52 | $qb->getParameters()->willReturn($parameters); |
||
53 | $parameters->count()->willReturn(1); |
||
54 | |||
55 | $qb->setParameter('comparison_1', '%bar')->shouldBeCalled(); |
||
56 | |||
57 | $this->match($qb, null); |
||
58 | } |
||
59 | |||
60 | View Code Duplication | public function it_ends_with_wildcard_when_using_starts_with(QueryBuilder $qb, ArrayCollection $parameters) |
|
0 ignored issues
–
show
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...
|
|||
61 | { |
||
62 | $this->beConstructedWith($this->field, $this->value, Like::STARTS_WITH, 'dqlAlias'); |
||
63 | $qb->getParameters()->willReturn($parameters); |
||
64 | $parameters->count()->willReturn(1); |
||
65 | |||
66 | $qb->setParameter('comparison_1', 'bar%')->shouldBeCalled(); |
||
67 | |||
68 | $this->match($qb, null); |
||
69 | } |
||
70 | } |
||
71 |
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.