This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Doctrine\Bundle\DoctrineBundle\Tests\Twig; |
||
4 | |||
5 | use Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension; |
||
6 | use PHPUnit\Framework\TestCase; |
||
7 | |||
8 | class DoctrineExtensionTest extends TestCase |
||
9 | { |
||
10 | View Code Duplication | public function testReplaceQueryParametersWithPostgresCasting() : void |
|
0 ignored issues
–
show
|
|||
11 | { |
||
12 | $extension = new DoctrineExtension(); |
||
13 | $query = 'a=? OR (1)::string OR b=?'; |
||
14 | $parameters = [1, 2]; |
||
15 | |||
16 | $result = $extension->replaceQueryParameters($query, $parameters); |
||
17 | $this->assertEquals('a=1 OR (1)::string OR b=2', $result); |
||
18 | } |
||
19 | |||
20 | View Code Duplication | public function testReplaceQueryParametersWithStartingIndexAtOne() : void |
|
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. ![]() |
|||
21 | { |
||
22 | $extension = new DoctrineExtension(); |
||
23 | $query = 'a=? OR b=?'; |
||
24 | $parameters = [ |
||
25 | 1 => 1, |
||
26 | 2 => 2, |
||
27 | ]; |
||
28 | |||
29 | $result = $extension->replaceQueryParameters($query, $parameters); |
||
30 | $this->assertEquals('a=1 OR b=2', $result); |
||
31 | } |
||
32 | |||
33 | View Code Duplication | public function testReplaceQueryParameters() : void |
|
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. ![]() |
|||
34 | { |
||
35 | $extension = new DoctrineExtension(); |
||
36 | $query = 'a=? OR b=?'; |
||
37 | $parameters = [ |
||
38 | 1, |
||
39 | 2, |
||
40 | ]; |
||
41 | |||
42 | $result = $extension->replaceQueryParameters($query, $parameters); |
||
43 | $this->assertEquals('a=1 OR b=2', $result); |
||
44 | } |
||
45 | |||
46 | public function testReplaceQueryParametersWithNamedIndex() : void |
||
47 | { |
||
48 | $extension = new DoctrineExtension(); |
||
49 | $query = 'a=:a OR b=:b'; |
||
50 | $parameters = [ |
||
51 | 'a' => 1, |
||
52 | 'b' => 2, |
||
53 | ]; |
||
54 | |||
55 | $result = $extension->replaceQueryParameters($query, $parameters); |
||
56 | $this->assertEquals('a=1 OR b=2', $result); |
||
57 | } |
||
58 | |||
59 | View Code Duplication | public function testReplaceQueryParametersWithEmptyArray() : void |
|
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. ![]() |
|||
60 | { |
||
61 | $extension = new DoctrineExtension(); |
||
62 | $query = 'IN (?)'; |
||
63 | $parameters = [ |
||
64 | [], |
||
65 | ]; |
||
66 | |||
67 | $result = $extension->replaceQueryParameters($query, $parameters); |
||
68 | $this->assertEquals('IN (NULL)', $result); |
||
69 | } |
||
70 | |||
71 | public function testEscapeBinaryParameter() : void |
||
72 | { |
||
73 | $binaryString = pack('H*', '9d40b8c1417f42d099af4782ec4b20b6'); |
||
74 | $this->assertEquals('0x9D40B8C1417F42D099AF4782EC4B20B6', DoctrineExtension::escapeFunction($binaryString)); |
||
75 | } |
||
76 | |||
77 | public function testEscapeStringParameter() : void |
||
78 | { |
||
79 | $this->assertEquals("'test string'", DoctrineExtension::escapeFunction('test string')); |
||
80 | } |
||
81 | |||
82 | public function testEscapeArrayParameter() : void |
||
83 | { |
||
84 | $this->assertEquals("1, NULL, 'test', foo, NULL", DoctrineExtension::escapeFunction([1, null, 'test', new DummyClass('foo'), []])); |
||
85 | } |
||
86 | |||
87 | public function testEscapeObjectParameter() : void |
||
88 | { |
||
89 | $object = new DummyClass('bar'); |
||
90 | $this->assertEquals('bar', DoctrineExtension::escapeFunction($object)); |
||
91 | } |
||
92 | |||
93 | public function testEscapeNullParameter() : void |
||
94 | { |
||
95 | $this->assertEquals('NULL', DoctrineExtension::escapeFunction(null)); |
||
96 | } |
||
97 | |||
98 | public function testEscapeBooleanParameter() : void |
||
99 | { |
||
100 | $this->assertEquals('1', DoctrineExtension::escapeFunction(true)); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @group legacy |
||
105 | */ |
||
106 | public function testItHighlightsSqlQueriesUsingCssClasses() : void |
||
107 | { |
||
108 | $extension = new DoctrineExtension(); |
||
109 | self::assertStringContainsString( |
||
110 | 'class=', |
||
111 | $extension->formatQuery('CREATE DATABASE 📚;') |
||
112 | ); |
||
113 | self::assertStringContainsString( |
||
114 | 'class=', |
||
115 | $extension->formatSql('CREATE DATABASE 📚;', true) |
||
116 | ); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @group legacy |
||
121 | */ |
||
122 | View Code Duplication | public function testItDoesNotOutputDuplicatePreTags() : void |
|
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. ![]() |
|||
123 | { |
||
124 | $extension = new DoctrineExtension(); |
||
125 | self::assertSame( |
||
126 | 1, |
||
127 | substr_count($extension->formatQuery('CREATE DATABASE 📚;'), '<pre') |
||
128 | ); |
||
129 | self::assertSame( |
||
130 | 1, |
||
131 | substr_count($extension->formatSQL('CREATE DATABASE 📚;', true), '<pre') |
||
132 | ); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @group legacy |
||
137 | */ |
||
138 | View Code Duplication | public function testItUsesCssOnTheDivTag() : void |
|
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. ![]() |
|||
139 | { |
||
140 | $extension = new DoctrineExtension(); |
||
141 | self::assertSame( |
||
142 | 1, |
||
143 | substr_count($extension->formatQuery('CREATE DATABASE 📚;'), '<div class=') |
||
144 | ); |
||
145 | self::assertSame( |
||
146 | 1, |
||
147 | substr_count($extension->formatQuery('CREATE DATABASE 📚;'), '<pre>') |
||
148 | ); |
||
149 | } |
||
150 | |||
151 | public function testItUsesCssOnThePreTag() : void |
||
152 | { |
||
153 | $extension = new DoctrineExtension(); |
||
154 | self::assertSame( |
||
155 | 1, |
||
156 | substr_count($extension->formatSQL('CREATE DATABASE 📚;', true), '<pre class=') |
||
157 | ); |
||
158 | } |
||
159 | } |
||
160 | |||
161 | class DummyClass |
||
162 | { |
||
163 | /** @var string */ |
||
164 | protected $str; |
||
165 | |||
166 | public function __construct(string $str) |
||
167 | { |
||
168 | $this->str = $str; |
||
169 | } |
||
170 | |||
171 | public function __toString() : string |
||
172 | { |
||
173 | return $this->str; |
||
174 | } |
||
175 | } |
||
176 |
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.