testOrderByMultipleColumns()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\ORM\Query;
6
7
use Doctrine\ORM\Annotation as ORM;
8
use Doctrine\ORM\EntityManagerInterface;
9
use Doctrine\ORM\Query;
10
use Doctrine\ORM\Query\QueryException;
11
use Doctrine\Tests\Mocks\MockTreeWalker;
12
use Doctrine\Tests\OrmTestCase;
13
use const PHP_EOL;
14
15
class LanguageRecognitionTest extends OrmTestCase
16
{
17
    /** @var EntityManagerInterface */
18
    private $em;
19
20
    protected function setUp() : void
21
    {
22
        $this->em = $this->getTestEntityManager();
23
    }
24
25
    public function assertValidDQL($dql, $debug = false)
26
    {
27
        try {
28
            $parserResult = $this->parseDql($dql);
0 ignored issues
show
Unused Code introduced by
The assignment to $parserResult is dead and can be removed.
Loading history...
29
            $this->addToAssertionCount(1);
30
        } catch (QueryException $e) {
31
            if ($debug) {
32
                echo $e->getTraceAsString() . PHP_EOL;
33
            }
34
35
            $this->fail($e->getMessage());
36
        }
37
    }
38
39
    public function assertInvalidDQL($dql, $debug = false)
40
    {
41
        try {
42
            $parserResult = $this->parseDql($dql);
0 ignored issues
show
Unused Code introduced by
The assignment to $parserResult is dead and can be removed.
Loading history...
43
44
            $this->fail('No syntax errors were detected, when syntax errors were expected');
45
        } catch (QueryException $e) {
46
            if ($debug) {
47
                echo $e->getMessage() . PHP_EOL;
48
                echo $e->getTraceAsString() . PHP_EOL;
49
            }
50
            $this->addToAssertionCount(1);
51
        }
52
    }
53
54
    public function parseDql($dql, $hints = [])
55
    {
56
        $query = $this->em->createQuery($dql);
57
        $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
58
        $query->setDQL($dql);
59
60
        foreach ($hints as $key => $value) {
61
            $query->setHint($key, $value);
62
        }
63
64
        $parser = new Query\Parser($query);
65
66
        // We do NOT test SQL output here. That only unnecessarily slows down the tests!
67
        $parser->setCustomOutputTreeWalker(MockTreeWalker::class);
68
69
        return $parser->parse();
70
    }
71
72
    public function testEmptyQueryString() : void
73
    {
74
        self::assertInvalidDQL('');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
        self::/** @scrutinizer ignore-call */ 
75
              assertInvalidDQL('');
Loading history...
75
    }
76
77
    public function testPlainFromClauseWithAlias() : void
78
    {
79
        self::assertValidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

79
        self::/** @scrutinizer ignore-call */ 
80
              assertValidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
80
    }
81
82
    public function testSelectSingleComponentWithAsterisk() : void
83
    {
84
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

84
        self::/** @scrutinizer ignore-call */ 
85
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
85
    }
86
87
    /**
88
     * @dataProvider invalidDQL
89
     */
90
    public function testRejectsInvalidDQL($dql) : void
91
    {
92
        $this->expectException(QueryException::class);
93
94
        $this->parseDql($dql);
95
    }
96
97
    public function invalidDQL()
98
    {
99
        return [
100
101
            ['SELECT \'foo\' AS foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
102
            /* Checks for invalid IdentificationVariables and AliasIdentificationVariables */
103
            ['SELECT \foo FROM Doctrine\Tests\Models\CMS\CmsUser \foo'],
104
            ['SELECT foo\ FROM Doctrine\Tests\Models\CMS\CmsUser foo\\'],
105
            ['SELECT foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser foo\bar'],
106
            ['SELECT foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser foo:bar'],
107
            ['SELECT foo: FROM Doctrine\Tests\Models\CMS\CmsUser foo:'],
108
109
            /* Checks for invalid AbstractSchemaName */
110
            ['SELECT u FROM UnknownClass u'],  // unknown
111
            ['SELECT u FROM \Unknown\Class u'], // unknown, leading backslash
112
            ['SELECT u FROM Unknown\\\\Class u'], // unknown, syntactically bogus (duplicate \\)
113
            ['SELECT u FROM Unknown\Class\ u'], // unknown, syntactically bogus (trailing \)
114
            ['SELECT u FROM Unknown::Class u'], // unknown, with PAAMAYIM_NEKUDOTAYIM
115
            ['SELECT u FROM Doctrine\Tests\Models\CMS\\\\CmsUser u'], // syntactically bogus (duplicate \\)array('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser\ u'), // syntactically bogus (trailing \)
116
            ['SELECT u FROM CMS::User u'],
117
118
            /* Checks for invalid AliasResultVariable */
119
            ['SELECT \'foo\' AS \foo FROM Doctrine\Tests\Models\CMS\CmsUser u'],
120
            ['SELECT \'foo\' AS \foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
121
            ['SELECT \'foo\' AS foo\ FROM Doctrine\Tests\Models\CMS\CmsUser u'],
122
            ['SELECT \'foo\' AS foo\\\\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
123
            ['SELECT \'foo\' AS foo: FROM Doctrine\Tests\Models\CMS\CmsUser u'],
124
            ['SELECT \'foo\' AS foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
125
        ];
126
    }
127
128
    public function testSelectSingleComponentWithMultipleColumns() : void
129
    {
130
        self::assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

130
        self::/** @scrutinizer ignore-call */ 
131
              assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
131
    }
132
133
    public function testSelectMultipleComponentsUsingMultipleFrom() : void
134
    {
135
        self::assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

135
        self::/** @scrutinizer ignore-call */ 
136
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user');
Loading history...
136
    }
137
138
    public function testSelectMultipleComponentsWithAsterisk() : void
139
    {
140
        self::assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

140
        self::/** @scrutinizer ignore-call */ 
141
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
Loading history...
141
    }
142
143
    public function testSelectDistinctIsSupported() : void
144
    {
145
        self::assertValidDQL('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

145
        self::/** @scrutinizer ignore-call */ 
146
              assertValidDQL('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
146
    }
147
148
    public function testAggregateFunctionInSelect() : void
149
    {
150
        self::assertValidDQL('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

150
        self::/** @scrutinizer ignore-call */ 
151
              assertValidDQL('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
151
    }
152
153
    public function testMultipleParenthesisInSelect() : void
154
    {
155
        self::assertValidDQL('SELECT (((u.id))) as v FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

155
        self::/** @scrutinizer ignore-call */ 
156
              assertValidDQL('SELECT (((u.id))) as v FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
156
    }
157
158
    public function testDuplicatedAliasInAggregateFunction() : void
159
    {
160
        self::assertInvalidDQL('SELECT COUNT(u.id) AS num, SUM(u.id) AS num FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

160
        self::/** @scrutinizer ignore-call */ 
161
              assertInvalidDQL('SELECT COUNT(u.id) AS num, SUM(u.id) AS num FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
161
    }
162
163
    public function testAggregateFunctionWithDistinctInSelect() : void
164
    {
165
        self::assertValidDQL('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

165
        self::/** @scrutinizer ignore-call */ 
166
              assertValidDQL('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
166
    }
167
168
    public function testFunctionalExpressionsSupportedInWherePart() : void
169
    {
170
        self::assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

170
        self::/** @scrutinizer ignore-call */ 
171
              assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
Loading history...
171
    }
172
173
    public function testArithmeticExpressionsSupportedInWherePart() : void
174
    {
175
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

175
        self::/** @scrutinizer ignore-call */ 
176
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
Loading history...
176
    }
177
178
    public function testInExpressionSupportedInWherePart() : void
179
    {
180
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

180
        self::/** @scrutinizer ignore-call */ 
181
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)');
Loading history...
181
    }
182
183
    public function testInExpressionWithoutSpacesSupportedInWherePart() : void
184
    {
185
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1,2,3)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

185
        self::/** @scrutinizer ignore-call */ 
186
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1,2,3)');
Loading history...
186
    }
187
188
    public function testNotInExpressionSupportedInWherePart() : void
189
    {
190
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

190
        self::/** @scrutinizer ignore-call */ 
191
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)');
Loading history...
191
    }
192
193
    public function testInExpressionWithSingleValuedAssociationPathExpression() : void
194
    {
195
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

195
        self::/** @scrutinizer ignore-call */ 
196
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)');
Loading history...
196
    }
197
198
    public function testInvalidInExpressionWithCollectionValuedAssociationPathExpression() : void
199
    {
200
        self::assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IN (?1, ?2)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

200
        self::/** @scrutinizer ignore-call */ 
201
              assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IN (?1, ?2)');
Loading history...
201
    }
202
203
    public function testInstanceOfExpressionSupportedInWherePart() : void
204
    {
205
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

205
        self::/** @scrutinizer ignore-call */ 
206
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee');
Loading history...
206
    }
207
208
    public function testInstanceOfExpressionWithInputParamSupportedInWherePart() : void
209
    {
210
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

210
        self::/** @scrutinizer ignore-call */ 
211
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1');
Loading history...
211
    }
212
213
    public function testNotInstanceOfExpressionSupportedInWherePart() : void
214
    {
215
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

215
        self::/** @scrutinizer ignore-call */ 
216
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1');
Loading history...
216
    }
217
218
    public function testExistsExpressionSupportedInWherePart() : void
219
    {
220
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

220
        self::/** @scrutinizer ignore-call */ 
221
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)');
Loading history...
221
    }
222
223
    public function testNotExistsExpressionSupportedInWherePart() : void
224
    {
225
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

225
        self::/** @scrutinizer ignore-call */ 
226
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)');
Loading history...
226
    }
227
228
    public function testAggregateFunctionInHavingClause() : void
229
    {
230
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

230
        self::/** @scrutinizer ignore-call */ 
231
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2');
Loading history...
231
        self::assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'romanb'");
232
    }
233
234
    public function testLeftJoin() : void
235
    {
236
        self::assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

236
        self::/** @scrutinizer ignore-call */ 
237
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p');
Loading history...
237
    }
238
239
    public function testJoin() : void
240
    {
241
        self::assertValidDQL('SELECT u,p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

241
        self::/** @scrutinizer ignore-call */ 
242
              assertValidDQL('SELECT u,p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
Loading history...
242
    }
243
244
    public function testInnerJoin() : void
245
    {
246
        self::assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

246
        self::/** @scrutinizer ignore-call */ 
247
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p');
Loading history...
247
    }
248
249
    public function testMultipleLeftJoin() : void
250
    {
251
        self::assertValidDQL('SELECT u, a, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a LEFT JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

251
        self::/** @scrutinizer ignore-call */ 
252
              assertValidDQL('SELECT u, a, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a LEFT JOIN u.phonenumbers p');
Loading history...
252
    }
253
254
    public function testMultipleInnerJoin() : void
255
    {
256
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INNER JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

256
        self::/** @scrutinizer ignore-call */ 
257
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INNER JOIN u.phonenumbers p');
Loading history...
257
    }
258
259
    public function testMixingOfJoins() : void
260
    {
261
        self::assertValidDQL('SELECT u.name, a.topic, p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

261
        self::/** @scrutinizer ignore-call */ 
262
              assertValidDQL('SELECT u.name, a.topic, p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p');
Loading history...
262
    }
263
264
    public function testJoinClassPathUsingWITH() : void
265
    {
266
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WITH a.user = u.id');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

266
        self::/** @scrutinizer ignore-call */ 
267
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WITH a.user = u.id');
Loading history...
267
    }
268
269
    /**
270
     * @group DDC-3701
271
     */
272
    public function testJoinClassPathUsingWHERE() : void
273
    {
274
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = u.id');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

274
        self::/** @scrutinizer ignore-call */ 
275
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = u.id');
Loading history...
275
    }
276
277
    /**
278
     * @group DDC-3701
279
     */
280
    public function testDDC3701WHEREIsNotWITH() : void
281
    {
282
        self::assertInvalidDQL('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.id = c.salesPerson WHERE c.completed = true');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

282
        self::/** @scrutinizer ignore-call */ 
283
              assertInvalidDQL('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.id = c.salesPerson WHERE c.completed = true');
Loading history...
283
    }
284
285
    public function testOrderBySingleColumn() : void
286
    {
287
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

287
        self::/** @scrutinizer ignore-call */ 
288
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name');
Loading history...
288
    }
289
290
    public function testOrderBySingleColumnAscending() : void
291
    {
292
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

292
        self::/** @scrutinizer ignore-call */ 
293
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC');
Loading history...
293
    }
294
295
    public function testOrderBySingleColumnDescending() : void
296
    {
297
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

297
        self::/** @scrutinizer ignore-call */ 
298
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC');
Loading history...
298
    }
299
300
    public function testOrderByMultipleColumns() : void
301
    {
302
        self::assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

302
        self::/** @scrutinizer ignore-call */ 
303
              assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC');
Loading history...
303
    }
304
305
    public function testSubselectInInExpression() : void
306
    {
307
        self::assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = 'zYne')");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

307
        self::/** @scrutinizer ignore-call */ 
308
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = 'zYne')");
Loading history...
308
    }
309
310
    public function testSubselectInSelectPart() : void
311
    {
312
        self::assertValidDQL("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

312
        self::/** @scrutinizer ignore-call */ 
313
              assertValidDQL("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
Loading history...
313
    }
314
315
    public function testArithmeticExpressionInSelectPart() : void
316
    {
317
        self::assertValidDQL('SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

317
        self::/** @scrutinizer ignore-call */ 
318
              assertValidDQL('SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
318
    }
319
320
    public function testArithmeticExpressionInSubselectPart() : void
321
    {
322
        self::assertValidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

322
        self::/** @scrutinizer ignore-call */ 
323
              assertValidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
Loading history...
323
    }
324
325
    public function testArithmeticExpressionWithParenthesisInSubselectPart() : void
326
    {
327
        self::assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

327
        self::/** @scrutinizer ignore-call */ 
328
              assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
Loading history...
328
    }
329
330
    /**
331
     * @group DDC-1079
332
     */
333
    public function testSelectLiteralInSubselect() : void
334
    {
335
        self::assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

335
        self::/** @scrutinizer ignore-call */ 
336
              assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
336
        self::assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
337
    }
338
339
    /**
340
     * @group DDC-1077
341
     */
342
    public function testConstantValueInSelect() : void
343
    {
344
        self::assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", true);
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

344
        self::/** @scrutinizer ignore-call */ 
345
              assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", true);
Loading history...
345
    }
346
347
    public function testDuplicateAliasInSubselectPart() : void
348
    {
349
        self::assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

349
        self::/** @scrutinizer ignore-call */ 
350
              assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
Loading history...
350
    }
351
352
    public function testPositionalInputParameter() : void
353
    {
354
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

354
        self::/** @scrutinizer ignore-call */ 
355
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1');
Loading history...
355
    }
356
357
    public function testNamedInputParameter() : void
358
    {
359
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

359
        self::/** @scrutinizer ignore-call */ 
360
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
Loading history...
360
    }
361
362
    public function testJoinConditionOverrideNotSupported() : void
363
    {
364
        self::assertInvalidDQL("SELECT u.name, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

364
        self::/** @scrutinizer ignore-call */ 
365
              assertInvalidDQL("SELECT u.name, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
Loading history...
365
    }
366
367
    public function testIndexByClauseWithOneComponent() : void
368
    {
369
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

369
        self::/** @scrutinizer ignore-call */ 
370
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
Loading history...
370
    }
371
372
    public function testIndexBySupportsJoins() : void
373
    {
374
        self::assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.id'); // INDEX BY is now referring to articles
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

374
        self::/** @scrutinizer ignore-call */ 
375
              assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.id'); // INDEX BY is now referring to articles
Loading history...
375
    }
376
377
    public function testIndexBySupportsJoins2() : void
378
    {
379
        self::assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p INDEX BY p.phonenumber');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

379
        self::/** @scrutinizer ignore-call */ 
380
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p INDEX BY p.phonenumber');
Loading history...
380
    }
381
382
    public function testBetweenExpressionSupported() : void
383
    {
384
        self::assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

384
        self::/** @scrutinizer ignore-call */ 
385
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
Loading history...
385
    }
386
387
    public function testNotBetweenExpressionSupported() : void
388
    {
389
        self::assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

389
        self::/** @scrutinizer ignore-call */ 
390
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
Loading history...
390
    }
391
392
    public function testLikeExpression() : void
393
    {
394
        self::assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

394
        self::/** @scrutinizer ignore-call */ 
395
              assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'");
Loading history...
395
    }
396
397
    public function testNotLikeExpression() : void
398
    {
399
        self::assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

399
        self::/** @scrutinizer ignore-call */ 
400
              assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'");
Loading history...
400
    }
401
402
    public function testLikeExpressionWithCustomEscapeCharacter() : void
403
    {
404
        self::assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

404
        self::/** @scrutinizer ignore-call */ 
405
              assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
Loading history...
405
    }
406
407
    public function testFieldComparisonWithoutAlias() : void
408
    {
409
        self::assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE id = 1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

409
        self::/** @scrutinizer ignore-call */ 
410
              assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE id = 1');
Loading history...
410
    }
411
412
    public function testDuplicatedAliasDeclaration() : void
413
    {
414
        self::assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles u WHERE u.id = 1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

414
        self::/** @scrutinizer ignore-call */ 
415
              assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles u WHERE u.id = 1');
Loading history...
415
    }
416
417
    public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression() : void
418
    {
419
        // This should be allowed because avatar is a single-value association.
420
        // SQL: SELECT ... FROM forum_user fu INNER JOIN forum_avatar fa ON fu.avatar_id = fa.id WHERE fa.id = ?
421
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a WHERE a.id = ?1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

421
        self::/** @scrutinizer ignore-call */ 
422
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a WHERE a.id = ?1');
Loading history...
422
    }
423
424
    public function testImplicitJoinInWhereOnCollectionValuedPathExpression() : void
425
    {
426
        // This should be forbidden, because articles is a collection
427
        self::assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a WHERE a.title = ?');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

427
        self::/** @scrutinizer ignore-call */ 
428
              assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a WHERE a.title = ?');
Loading history...
428
    }
429
430
    public function testInvalidSyntaxIsRejected() : void
431
    {
432
        self::assertInvalidDQL('FOOBAR CmsUser');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

432
        self::/** @scrutinizer ignore-call */ 
433
              assertInvalidDQL('FOOBAR CmsUser');
Loading history...
433
        self::assertInvalidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles');
434
        self::assertInvalidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles.comments');
435
436
        // Currently UNDEFINED OFFSET error
437
        self::assertInvalidDQL('SELECT c FROM CmsUser.articles.comments c');
438
    }
439
440
    public function testUpdateWorksWithOneField() : void
441
    {
442
        self::assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

442
        self::/** @scrutinizer ignore-call */ 
443
              assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'");
Loading history...
443
    }
444
445
    public function testUpdateWorksWithMultipleFields() : void
446
    {
447
        self::assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

447
        self::/** @scrutinizer ignore-call */ 
448
              assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'");
Loading history...
448
    }
449
450
    public function testUpdateSupportsConditions() : void
451
    {
452
        self::assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

452
        self::/** @scrutinizer ignore-call */ 
453
              assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5");
Loading history...
453
    }
454
455
    public function testDeleteAll() : void
456
    {
457
        self::assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

457
        self::/** @scrutinizer ignore-call */ 
458
              assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
458
    }
459
460
    public function testDeleteWithCondition() : void
461
    {
462
        self::assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = 3');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

462
        self::/** @scrutinizer ignore-call */ 
463
              assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = 3');
Loading history...
463
    }
464
465
    /**
466
     * The main use case for this generalized style of join is when a join condition
467
     * does not involve a foreign key relationship that is mapped to an entity relationship.
468
     */
469
    public function testImplicitJoinWithCartesianProductAndConditionInWhere() : void
470
    {
471
        self::assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

471
        self::/** @scrutinizer ignore-call */ 
472
              assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic');
Loading history...
472
    }
473
474
    public function testAllExpressionWithCorrelatedSubquery() : void
475
    {
476
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

476
        self::/** @scrutinizer ignore-call */ 
477
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
Loading history...
477
    }
478
479
    public function testCustomJoinsAndWithKeywordSupported() : void
480
    {
481
        self::assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p WITH p.phonenumber = 123 WHERE u.id = 1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

481
        self::/** @scrutinizer ignore-call */ 
482
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p WITH p.phonenumber = 123 WHERE u.id = 1');
Loading history...
482
    }
483
484
    public function testAnyExpressionWithCorrelatedSubquery() : void
485
    {
486
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ANY (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

486
        self::/** @scrutinizer ignore-call */ 
487
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ANY (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
Loading history...
487
    }
488
489
    public function testSomeExpressionWithCorrelatedSubquery() : void
490
    {
491
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > SOME (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

491
        self::/** @scrutinizer ignore-call */ 
492
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > SOME (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
Loading history...
492
    }
493
494
    public function testArithmeticExpressionWithoutParenthesisInWhereClause() : void
495
    {
496
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) + 1 > 10');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

496
        self::/** @scrutinizer ignore-call */ 
497
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) + 1 > 10');
Loading history...
497
    }
498
499
    public function testMemberOfExpression() : void
500
    {
501
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

501
        self::/** @scrutinizer ignore-call */ 
502
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers');
Loading history...
502
        //self::assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE 'Joe' MEMBER OF u.nicknames");
503
    }
504
505
    public function testSizeFunction() : void
506
    {
507
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

507
        self::/** @scrutinizer ignore-call */ 
508
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1');
Loading history...
508
    }
509
510
    public function testEmptyCollectionComparisonExpression() : void
511
    {
512
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

512
        self::/** @scrutinizer ignore-call */ 
513
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY');
Loading history...
513
    }
514
515
    public function testSingleValuedAssociationFieldInWhere() : void
516
    {
517
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

517
        self::/** @scrutinizer ignore-call */ 
518
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
Loading history...
518
        self::assertValidDQL('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1');
519
    }
520
521
    public function testBooleanLiteralInWhere() : void
522
    {
523
        self::assertValidDQL('SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

523
        self::/** @scrutinizer ignore-call */ 
524
              assertValidDQL('SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true');
Loading history...
524
    }
525
526
    public function testSubqueryInSelectExpression() : void
527
    {
528
        self::assertValidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

528
        self::/** @scrutinizer ignore-call */ 
529
              assertValidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
529
    }
530
531
    public function testUsageOfQComponentOutsideSubquery() : void
532
    {
533
        self::assertInvalidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u WHERE p.user = ?1');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

533
        self::/** @scrutinizer ignore-call */ 
534
              assertInvalidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u WHERE p.user = ?1');
Loading history...
534
    }
535
536
    public function testUnknownAbstractSchemaName() : void
537
    {
538
        self::assertInvalidDQL('SELECT u FROM UnknownClassName u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

538
        self::/** @scrutinizer ignore-call */ 
539
              assertInvalidDQL('SELECT u FROM UnknownClassName u');
Loading history...
539
    }
540
541
    public function testCorrectPartialObjectLoad() : void
542
    {
543
        self::assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

543
        self::/** @scrutinizer ignore-call */ 
544
              assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
544
    }
545
546
    public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier() : void
547
    {
548
        self::assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

548
        self::/** @scrutinizer ignore-call */ 
549
              assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
549
    }
550
551
    public function testScalarExpressionInSelect() : void
552
    {
553
        self::assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

553
        self::/** @scrutinizer ignore-call */ 
554
              assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
554
    }
555
556
    public function testInputParameterInSelect() : void
557
    {
558
        self::assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

558
        self::/** @scrutinizer ignore-call */ 
559
              assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
559
    }
560
561
    /**
562
     * @group DDC-1091
563
     */
564
    public function testCustomFunctionsReturningStringInStringPrimary() : void
565
    {
566
        $this->em->getConfiguration()->addCustomStringFunction('CC', Query\AST\Functions\ConcatFunction::class);
567
568
        self::assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true);
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

568
        self::/** @scrutinizer ignore-call */ 
569
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true);
Loading history...
569
    }
570
571
    /**
572
     * @group DDC-505
573
     */
574
    public function testDQLKeywordInJoinIsAllowed() : void
575
    {
576
        self::assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

576
        self::/** @scrutinizer ignore-call */ 
577
              assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g');
Loading history...
577
    }
578
579
    /**
580
     * @group DDC-505
581
     */
582
    public function testDQLKeywordInConditionIsAllowed() : void
583
    {
584
        self::assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

584
        self::/** @scrutinizer ignore-call */ 
585
              assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0');
Loading history...
585
    }
586
587
    /* The exception is currently thrown in the SQLWalker, not earlier.
588
    public function testInverseSideSingleValuedAssociationPathNotAllowed() : void
589
    {
590
        self::assertInvalidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
591
    }
592
    */
593
594
    /**
595
     * @group DDC-617
596
     */
597
    public function testSelectOnlyNonRootEntityAlias() : void
598
    {
599
        self::assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

599
        self::/** @scrutinizer ignore-call */ 
600
              assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g');
Loading history...
600
    }
601
602
    /**
603
     * @group DDC-1108
604
     */
605
    public function testInputParameterSingleChar() : void
606
    {
607
        self::assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

607
        self::/** @scrutinizer ignore-call */ 
608
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q');
Loading history...
608
    }
609
610
    /**
611
     * @group DDC-1053
612
     */
613
    public function testGroupBy() : void
614
    {
615
        self::assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

615
        self::/** @scrutinizer ignore-call */ 
616
              assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id');
Loading history...
616
    }
617
618
    /**
619
     * @group DDC-1053
620
     */
621
    public function testGroupByIdentificationVariable() : void
622
    {
623
        self::assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

623
        self::/** @scrutinizer ignore-call */ 
624
              assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g');
Loading history...
624
    }
625
626
    /**
627
     * @group DDC-1053
628
     */
629
    public function testGroupByUnknownIdentificationVariable() : void
630
    {
631
        self::assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...est::assertInvalidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

631
        self::/** @scrutinizer ignore-call */ 
632
              assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m');
Loading history...
632
    }
633
634
    /**
635
     * @group DDC-117
636
     */
637
    public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity() : void
638
    {
639
        self::assertValidDQL('SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

639
        self::/** @scrutinizer ignore-call */ 
640
              assertValidDQL('SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0');
Loading history...
640
    }
641
642
    /**
643
     * @group DDC-117
644
     */
645
    public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity() : void
646
    {
647
        self::assertValidDQL('SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

647
        self::/** @scrutinizer ignore-call */ 
648
              assertValidDQL('SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0');
Loading history...
648
    }
649
650
    public function testCaseSupportContainingNullIfExpression() : void
651
    {
652
        self::assertValidDQL('SELECT u.id, NULLIF(u.name, u.name) AS shouldBeNull FROM Doctrine\Tests\Models\CMS\CmsUser u');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

652
        self::/** @scrutinizer ignore-call */ 
653
              assertValidDQL('SELECT u.id, NULLIF(u.name, u.name) AS shouldBeNull FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
653
    }
654
655
    public function testCaseSupportContainingCoalesceExpression() : void
656
    {
657
        self::assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

657
        self::/** @scrutinizer ignore-call */ 
658
              assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
658
    }
659
660
    /**
661
     * @group DDC-1858
662
     */
663
    public function testHavingSupportIsNullExpression() : void
664
    {
665
        self::assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

665
        self::/** @scrutinizer ignore-call */ 
666
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL');
Loading history...
666
    }
667
668
    /**
669
     * @group DDC-3085
670
     */
671
    public function testHavingSupportResultVariableInNullComparisonExpression() : void
672
    {
673
        self::assertValidDQL('SELECT u AS user, SUM(a.id) AS score FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsAddress a WITH a.user = u GROUP BY u HAVING score IS NOT NULL AND score >= 5');
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

673
        self::/** @scrutinizer ignore-call */ 
674
              assertValidDQL('SELECT u AS user, SUM(a.id) AS score FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsAddress a WITH a.user = u GROUP BY u HAVING score IS NOT NULL AND score >= 5');
Loading history...
674
    }
675
676
    /**
677
     * @group DDC-1858
678
     */
679
    public function testHavingSupportLikeExpression() : void
680
    {
681
        self::assertValidDQL("SELECT _u.id, count(_articles) as uuuu FROM Doctrine\Tests\Models\CMS\CmsUser _u LEFT JOIN _u.articles _articles GROUP BY _u HAVING uuuu LIKE '3'");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

681
        self::/** @scrutinizer ignore-call */ 
682
              assertValidDQL("SELECT _u.id, count(_articles) as uuuu FROM Doctrine\Tests\Models\CMS\CmsUser _u LEFT JOIN _u.articles _articles GROUP BY _u HAVING uuuu LIKE '3'");
Loading history...
682
    }
683
684
    /**
685
     * @group DDC-3018
686
     */
687
    public function testNewLiteralExpression() : void
688
    {
689
        self::assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', 1, true) FROM Doctrine\Tests\Models\CMS\CmsUser u");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

689
        self::/** @scrutinizer ignore-call */ 
690
              assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', 1, true) FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
690
    }
691
692
    /**
693
     * @group DDC-3075
694
     */
695
    public function testNewLiteralWithSubselectExpression() : void
696
    {
697
        self::assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser su), true) FROM Doctrine\Tests\Models\CMS\CmsUser u");
0 ignored issues
show
Bug Best Practice introduced by
The method Doctrine\Tests\ORM\Query...nTest::assertValidDQL() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

697
        self::/** @scrutinizer ignore-call */ 
698
              assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser su), true) FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
698
    }
699
700
    public function testStringPrimaryAcceptsAggregateExpression() : void
701
    {
702
        $this->assertValidDQL(
703
            'SELECT CONCAT(a.topic, MAX(a.version)) last FROM Doctrine\Tests\Models\CMS\CmsArticle a GROUP BY a'
704
        );
705
    }
706
}
707
708
/** @ORM\Entity */
709
class DQLKeywordsModelUser
710
{
711
    /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */
712
    private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
713
    /** @ORM\OneToOne(targetEntity=DQLKeywordsModelGroup::class) */
714
    private $group;
0 ignored issues
show
introduced by
The private property $group is not used, and could be removed.
Loading history...
715
}
716
717
/** @ORM\Entity */
718
class DQLKeywordsModelGroup
719
{
720
    /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */
721
    private $id;
722
    /** @ORM\Column */
723
    private $from;
0 ignored issues
show
introduced by
The private property $from is not used, and could be removed.
Loading history...
724
}
725
726
class DummyStruct
727
{
728
    public function __construct($id, $arg1, $arg2, $arg3)
0 ignored issues
show
Unused Code introduced by
The parameter $arg2 is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

728
    public function __construct($id, $arg1, /** @scrutinizer ignore-unused */ $arg2, $arg3)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

728
    public function __construct(/** @scrutinizer ignore-unused */ $id, $arg1, $arg2, $arg3)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $arg3 is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

728
    public function __construct($id, $arg1, $arg2, /** @scrutinizer ignore-unused */ $arg3)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $arg1 is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

728
    public function __construct($id, /** @scrutinizer ignore-unused */ $arg1, $arg2, $arg3)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
729
    {
730
    }
731
}
732