Completed
Pull Request — master (#566)
by Mike
08:10
created

testReplaceQueryParametersWithNamedIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the Doctrine Bundle
4
 *
5
 * The code was originally distributed inside the Symfony framework.
6
 *
7
 * (c) Fabien Potencier <[email protected]>
8
 * (c) Doctrine Project, Benjamin Eberlei <[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 Doctrine\Bundle\DoctrineBundle\Tests\Twig;
15
16
use Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension;
17
18
class DoctrineExtensionTest extends \PHPUnit_Framework_TestCase
19
{
20 View Code Duplication
    public function testReplaceQueryParametersWithPostgresCasting()
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...
21
    {
22
        $extension = new DoctrineExtension();
23
        $query = 'a=? OR (1)::string OR b=?';
24
        $parameters = array(1, 2);
25
26
        $result = $extension->replaceQueryParameters($query, $parameters, false);
0 ignored issues
show
Unused Code introduced by
The call to DoctrineExtension::replaceQueryParameters() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
27
        $this->assertEquals('a=1 OR (1)::string OR b=2', $result);
28
    }
29
30 View Code Duplication
    public function testReplaceQueryParametersWithStartingIndexAtOne()
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...
31
    {
32
        $extension = new DoctrineExtension();
33
        $query = 'a=? OR b=?';
34
        $parameters = array(
35
            1 => 1,
36
            2 => 2
37
        );
38
39
        $result = $extension->replaceQueryParameters($query, $parameters, false);
0 ignored issues
show
Unused Code introduced by
The call to DoctrineExtension::replaceQueryParameters() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
40
        $this->assertEquals('a=1 OR b=2', $result);
41
    }
42
43 View Code Duplication
    public function testReplaceQueryParameters()
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...
44
    {
45
        $extension = new DoctrineExtension();
46
        $query = 'a=? OR b=?';
47
        $parameters = array(
48
            1,
49
            2
50
        );
51
52
        $result = $extension->replaceQueryParameters($query, $parameters, false);
0 ignored issues
show
Unused Code introduced by
The call to DoctrineExtension::replaceQueryParameters() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
        $this->assertEquals('a=1 OR b=2', $result);
54
    }
55
56
    public function testReplaceQueryParametersWithNamedIndex()
57
    {
58
        $extension = new DoctrineExtension();
59
        $query = 'a=:a OR b=:b';
60
        $parameters = array(
61
            'a' => 1,
62
            'b' => 2
63
        );
64
65
        $result = $extension->replaceQueryParameters($query, $parameters, false);
0 ignored issues
show
Unused Code introduced by
The call to DoctrineExtension::replaceQueryParameters() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
66
        $this->assertEquals('a=1 OR b=2', $result);
67
    }
68
}
69