Failed Conditions
Pull Request — develop (#6873)
by
unknown
112:44 queued 47:41
created

testCaseSupportContainingCoalesceExpression()   A

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
14
class LanguageRecognitionTest extends OrmTestCase
15
{
16
    /**
17
     * @var EntityManagerInterface
18
     */
19
    private $em;
20
21
    protected function setUp()
22
    {
23
        $this->em = $this->getTestEntityManager();
24
    }
25
26 View Code Duplication
    public function assertValidDQL($dql, $debug = false)
27
    {
28
        try {
29
            $parserResult = $this->parseDql($dql);
0 ignored issues
show
Unused Code introduced by
The assignment to $parserResult is dead and can be removed.
Loading history...
30
            $this->addToAssertionCount(1);
31
        } catch (QueryException $e) {
32
            if ($debug) {
33
                echo $e->getTraceAsString() . PHP_EOL;
34
            }
35
36
            $this->fail($e->getMessage());
37
        }
38
    }
39
40 View Code Duplication
    public function assertInvalidDQL($dql, $debug = false)
41
    {
42
        try {
43
            $parserResult = $this->parseDql($dql);
0 ignored issues
show
Unused Code introduced by
The assignment to $parserResult is dead and can be removed.
Loading history...
44
45
            $this->fail('No syntax errors were detected, when syntax errors were expected');
46
        } catch (QueryException $e) {
47
            if ($debug) {
48
                echo $e->getMessage() . PHP_EOL;
49
                echo $e->getTraceAsString() . PHP_EOL;
50
            }
51
            $this->addToAssertionCount(1);
52
        }
53
    }
54
55
    public function parseDql($dql, $hints = [])
56
    {
57
        $query = $this->em->createQuery($dql);
58
        $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
59
        $query->setDQL($dql);
60
61
        foreach ($hints as $key => $value) {
62
        	$query->setHint($key, $value);
63
        }
64
65
        $parser = new Query\Parser($query);
66
67
        // We do NOT test SQL output here. That only unnecessarily slows down the tests!
68
        $parser->setCustomOutputTreeWalker(MockTreeWalker::class);
69
70
        return $parser->parse();
71
    }
72
73
    public function testEmptyQueryString()
74
    {
75
        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

75
        self::/** @scrutinizer ignore-call */ 
76
              assertInvalidDQL('');
Loading history...
76
    }
77
78
    public function testPlainFromClauseWithAlias()
79
    {
80
        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

80
        self::/** @scrutinizer ignore-call */ 
81
              assertValidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
81
    }
82
83
    public function testSelectSingleComponentWithAsterisk()
84
    {
85
        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

85
        self::/** @scrutinizer ignore-call */ 
86
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
86
    }
87
88
    /**
89
     * @dataProvider invalidDQL
90
     */
91
    public function testRejectsInvalidDQL($dql)
92
    {
93
        $this->expectException(QueryException::class);
94
95
        $this->em->getConfiguration()->setEntityNamespaces(
96
            [
97
            'Unknown' => 'Unknown',
98
            'CMS' => 'Doctrine\Tests\Models\CMS'
99
            ]
100
        );
101
102
        $this->parseDql($dql);
103
    }
104
105
    public function invalidDQL()
106
    {
107
        return [
108
109
            ['SELECT \'foo\' AS foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
110
            /* Checks for invalid IdentificationVariables and AliasIdentificationVariables */
111
            ['SELECT \foo FROM Doctrine\Tests\Models\CMS\CmsUser \foo'],
112
            ['SELECT foo\ FROM Doctrine\Tests\Models\CMS\CmsUser foo\\'],
113
            ['SELECT foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser foo\bar'],
114
            ['SELECT foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser foo:bar'],
115
            ['SELECT foo: FROM Doctrine\Tests\Models\CMS\CmsUser foo:'],
116
117
            /* Checks for invalid AbstractSchemaName */
118
            ['SELECT u FROM UnknownClass u'],  // unknown
119
            ['SELECT u FROM Unknown\Class u'], // unknown with namespace
120
            ['SELECT u FROM \Unknown\Class u'], // unknown, leading backslash
121
            ['SELECT u FROM Unknown\\\\Class u'], // unknown, syntactically bogus (duplicate \\)
122
            ['SELECT u FROM Unknown\Class\ u'], // unknown, syntactically bogus (trailing \)
123
            ['SELECT u FROM Unknown:Class u'], // unknown, with namespace alias
124
            ['SELECT u FROM Unknown::Class u'], // unknown, with PAAMAYIM_NEKUDOTAYIM
125
            ['SELECT u FROM Unknown:Class:Name u'], // unknown, with invalid namespace alias
126
            ['SELECT u FROM UnknownClass: u'], // unknown, with invalid namespace alias
127
            ['SELECT u FROM Unknown:Class: u'], // unknown, with invalid namespace alias
128
            ['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 \)
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
129
            ['SELECT u FROM CMS::User u'],
130
            ['SELECT u FROM CMS:User: u'],
131
            ['SELECT u FROM CMS:User:Foo u'],
132
133
            /* Checks for invalid AliasResultVariable */
134
            ['SELECT \'foo\' AS \foo FROM Doctrine\Tests\Models\CMS\CmsUser u'],
135
            ['SELECT \'foo\' AS \foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
136
            ['SELECT \'foo\' AS foo\ FROM Doctrine\Tests\Models\CMS\CmsUser u'],
137
            ['SELECT \'foo\' AS foo\\\\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
138
            ['SELECT \'foo\' AS foo: FROM Doctrine\Tests\Models\CMS\CmsUser u'],
139
            ['SELECT \'foo\' AS foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
140
        ];
141
    }
142
143
    public function testSelectSingleComponentWithMultipleColumns()
144
    {
145
        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

145
        self::/** @scrutinizer ignore-call */ 
146
              assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
146
    }
147
148
    public function testSelectMultipleComponentsUsingMultipleFrom()
149
    {
150
        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

150
        self::/** @scrutinizer ignore-call */ 
151
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user');
Loading history...
151
    }
152
153
    public function testSelectMultipleComponentsWithAsterisk()
154
    {
155
        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

155
        self::/** @scrutinizer ignore-call */ 
156
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
Loading history...
156
    }
157
158
    public function testSelectDistinctIsSupported()
159
    {
160
        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

160
        self::/** @scrutinizer ignore-call */ 
161
              assertValidDQL('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
161
    }
162
163
    public function testAggregateFunctionInSelect()
164
    {
165
        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

165
        self::/** @scrutinizer ignore-call */ 
166
              assertValidDQL('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
166
    }
167
168
    public function testMultipleParenthesisInSelect()
169
    {
170
        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

170
        self::/** @scrutinizer ignore-call */ 
171
              assertValidDQL('SELECT (((u.id))) as v FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
171
    }
172
173
    public function testDuplicatedAliasInAggregateFunction()
174
    {
175
        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

175
        self::/** @scrutinizer ignore-call */ 
176
              assertInvalidDQL('SELECT COUNT(u.id) AS num, SUM(u.id) AS num FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
176
    }
177
178
    public function testAggregateFunctionWithDistinctInSelect()
179
    {
180
        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

180
        self::/** @scrutinizer ignore-call */ 
181
              assertValidDQL('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
181
    }
182
183
    public function testFunctionalExpressionsSupportedInWherePart()
184
    {
185
        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

185
        self::/** @scrutinizer ignore-call */ 
186
              assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
Loading history...
186
    }
187
188
    public function testArithmeticExpressionsSupportedInWherePart()
189
    {
190
        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

190
        self::/** @scrutinizer ignore-call */ 
191
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
Loading history...
191
    }
192
193
    public function testInExpressionSupportedInWherePart()
194
    {
195
        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

195
        self::/** @scrutinizer ignore-call */ 
196
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)');
Loading history...
196
    }
197
198
    public function testInExpressionWithoutSpacesSupportedInWherePart()
199
    {
200
        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

200
        self::/** @scrutinizer ignore-call */ 
201
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1,2,3)');
Loading history...
201
    }
202
203
    public function testNotInExpressionSupportedInWherePart()
204
    {
205
        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

205
        self::/** @scrutinizer ignore-call */ 
206
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)');
Loading history...
206
    }
207
208
    public function testInExpressionWithSingleValuedAssociationPathExpression()
209
    {
210
        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

210
        self::/** @scrutinizer ignore-call */ 
211
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)");
Loading history...
211
    }
212
213
    public function testInvalidInExpressionWithCollectionValuedAssociationPathExpression()
214
    {
215
        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

215
        self::/** @scrutinizer ignore-call */ 
216
              assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IN (?1, ?2)");
Loading history...
216
    }
217
218
    public function testInstanceOfExpressionSupportedInWherePart()
219
    {
220
        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

220
        self::/** @scrutinizer ignore-call */ 
221
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee');
Loading history...
221
    }
222
223
    public function testInstanceOfExpressionWithInputParamSupportedInWherePart()
224
    {
225
        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

225
        self::/** @scrutinizer ignore-call */ 
226
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1');
Loading history...
226
    }
227
228
    public function testNotInstanceOfExpressionSupportedInWherePart()
229
    {
230
        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

230
        self::/** @scrutinizer ignore-call */ 
231
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1');
Loading history...
231
    }
232
233
    public function testExistsExpressionSupportedInWherePart()
234
    {
235
        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

235
        self::/** @scrutinizer ignore-call */ 
236
              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...
236
    }
237
238
    public function testNotExistsExpressionSupportedInWherePart()
239
    {
240
        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

240
        self::/** @scrutinizer ignore-call */ 
241
              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...
241
    }
242
243
    public function testAggregateFunctionInHavingClause()
244
    {
245
        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

245
        self::/** @scrutinizer ignore-call */ 
246
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2');
Loading history...
246
        self::assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'romanb'");
247
    }
248
249
    public function testLeftJoin()
250
    {
251
        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

251
        self::/** @scrutinizer ignore-call */ 
252
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p');
Loading history...
252
    }
253
254
    public function testJoin()
255
    {
256
        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

256
        self::/** @scrutinizer ignore-call */ 
257
              assertValidDQL('SELECT u,p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
Loading history...
257
    }
258
259
    public function testInnerJoin()
260
    {
261
        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

261
        self::/** @scrutinizer ignore-call */ 
262
              assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p');
Loading history...
262
    }
263
264
    public function testMultipleLeftJoin()
265
    {
266
        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

266
        self::/** @scrutinizer ignore-call */ 
267
              assertValidDQL('SELECT u, a, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a LEFT JOIN u.phonenumbers p');
Loading history...
267
    }
268
269
    public function testMultipleInnerJoin()
270
    {
271
        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

271
        self::/** @scrutinizer ignore-call */ 
272
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INNER JOIN u.phonenumbers p');
Loading history...
272
    }
273
274
    public function testMixingOfJoins()
275
    {
276
        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

276
        self::/** @scrutinizer ignore-call */ 
277
              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...
277
    }
278
279
    public function testJoinClassPathUsingWITH()
280
    {
281
        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

281
        self::/** @scrutinizer ignore-call */ 
282
              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...
282
    }
283
284
    /**
285
     * @group DDC-3701
286
     */
287
    public function testJoinClassPathUsingWHERE()
288
    {
289
        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

289
        self::/** @scrutinizer ignore-call */ 
290
              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...
290
    }
291
292
    /**
293
     * @group DDC-3701
294
     */
295
    public function testDDC3701WHEREIsNotWITH()
296
    {
297
        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

297
        self::/** @scrutinizer ignore-call */ 
298
              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...
298
    }
299
300
    public function testOrderBySingleColumn()
301
    {
302
        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

302
        self::/** @scrutinizer ignore-call */ 
303
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name');
Loading history...
303
    }
304
305
    public function testOrderBySingleColumnAscending()
306
    {
307
        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

307
        self::/** @scrutinizer ignore-call */ 
308
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC');
Loading history...
308
    }
309
310
    public function testOrderBySingleColumnDescending()
311
    {
312
        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

312
        self::/** @scrutinizer ignore-call */ 
313
              assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC');
Loading history...
313
    }
314
315
    public function testOrderByMultipleColumns()
316
    {
317
        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

317
        self::/** @scrutinizer ignore-call */ 
318
              assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC');
Loading history...
318
    }
319
320
    public function testSubselectInInExpression()
321
    {
322
        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

322
        self::/** @scrutinizer ignore-call */ 
323
              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...
323
    }
324
325
    public function testSubselectInSelectPart()
326
    {
327
        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

327
        self::/** @scrutinizer ignore-call */ 
328
              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...
328
    }
329
330
    public function testArithmeticExpressionInSelectPart()
331
    {
332
        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

332
        self::/** @scrutinizer ignore-call */ 
333
              assertValidDQL("SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
333
    }
334
335
    public function testArithmeticExpressionInSubselectPart()
336
    {
337
        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

337
        self::/** @scrutinizer ignore-call */ 
338
              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...
338
    }
339
340
    public function testArithmeticExpressionWithParenthesisInSubselectPart()
341
    {
342
        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

342
        self::/** @scrutinizer ignore-call */ 
343
              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...
343
    }
344
345
    /**
346
     * @group DDC-1079
347
     */
348
    public function testSelectLiteralInSubselect()
349
    {
350
        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

350
        self::/** @scrutinizer ignore-call */ 
351
              assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
351
        self::assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
352
    }
353
354
    /**
355
     * @group DDC-1077
356
     */
357
    public function testConstantValueInSelect()
358
    {
359
        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

359
        self::/** @scrutinizer ignore-call */ 
360
              assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", true);
Loading history...
360
    }
361
362
    public function testDuplicateAliasInSubselectPart()
363
    {
364
        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

364
        self::/** @scrutinizer ignore-call */ 
365
              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...
365
    }
366
367
    public function testPositionalInputParameter()
368
    {
369
        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

369
        self::/** @scrutinizer ignore-call */ 
370
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1');
Loading history...
370
    }
371
372
    public function testNamedInputParameter()
373
    {
374
        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

374
        self::/** @scrutinizer ignore-call */ 
375
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
Loading history...
375
    }
376
377
    public function testJoinConditionOverrideNotSupported()
378
    {
379
        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

379
        self::/** @scrutinizer ignore-call */ 
380
              assertInvalidDQL("SELECT u.name, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
Loading history...
380
    }
381
382
    public function testIndexByClauseWithOneComponent()
383
    {
384
        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

384
        self::/** @scrutinizer ignore-call */ 
385
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
Loading history...
385
    }
386
387
    public function testIndexBySupportsJoins()
388
    {
389
        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

389
        self::/** @scrutinizer ignore-call */ 
390
              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...
390
    }
391
392
    public function testIndexBySupportsJoins2()
393
    {
394
        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

394
        self::/** @scrutinizer ignore-call */ 
395
              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...
395
    }
396
397
    public function testBetweenExpressionSupported()
398
    {
399
        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

399
        self::/** @scrutinizer ignore-call */ 
400
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
Loading history...
400
    }
401
402
    public function testNotBetweenExpressionSupported()
403
    {
404
        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

404
        self::/** @scrutinizer ignore-call */ 
405
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
Loading history...
405
    }
406
407
    public function testLikeExpression()
408
    {
409
        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

409
        self::/** @scrutinizer ignore-call */ 
410
              assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'");
Loading history...
410
    }
411
412
    public function testNotLikeExpression()
413
    {
414
        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

414
        self::/** @scrutinizer ignore-call */ 
415
              assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'");
Loading history...
415
    }
416
417
    public function testLikeExpressionWithCustomEscapeCharacter()
418
    {
419
        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

419
        self::/** @scrutinizer ignore-call */ 
420
              assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
Loading history...
420
    }
421
422
    public function testFieldComparisonWithoutAlias()
423
    {
424
        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

424
        self::/** @scrutinizer ignore-call */ 
425
              assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE id = 1");
Loading history...
425
    }
426
427
    public function testDuplicatedAliasDeclaration()
428
    {
429
        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

429
        self::/** @scrutinizer ignore-call */ 
430
              assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles u WHERE u.id = 1");
Loading history...
430
    }
431
432
    public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression()
433
    {
434
        // This should be allowed because avatar is a single-value association.
435
        // SQL: SELECT ... FROM forum_user fu INNER JOIN forum_avatar fa ON fu.avatar_id = fa.id WHERE fa.id = ?
436
        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

436
        self::/** @scrutinizer ignore-call */ 
437
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a WHERE a.id = ?1");
Loading history...
437
    }
438
439
    public function testImplicitJoinInWhereOnCollectionValuedPathExpression()
440
    {
441
        // This should be forbidden, because articles is a collection
442
        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

442
        self::/** @scrutinizer ignore-call */ 
443
              assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a WHERE a.title = ?");
Loading history...
443
    }
444
445
    public function testInvalidSyntaxIsRejected()
446
    {
447
        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

447
        self::/** @scrutinizer ignore-call */ 
448
              assertInvalidDQL("FOOBAR CmsUser");
Loading history...
448
        self::assertInvalidDQL("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles");
449
        self::assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles.comments");
450
451
        // Currently UNDEFINED OFFSET error
452
        self::assertInvalidDQL("SELECT c FROM CmsUser.articles.comments c");
453
    }
454
455
    public function testUpdateWorksWithOneField()
456
    {
457
        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

457
        self::/** @scrutinizer ignore-call */ 
458
              assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'");
Loading history...
458
    }
459
460
    public function testUpdateWorksWithMultipleFields()
461
    {
462
        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

462
        self::/** @scrutinizer ignore-call */ 
463
              assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'");
Loading history...
463
    }
464
465
    public function testUpdateSupportsConditions()
466
    {
467
        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

467
        self::/** @scrutinizer ignore-call */ 
468
              assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5");
Loading history...
468
    }
469
470
    public function testDeleteAll()
471
    {
472
        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

472
        self::/** @scrutinizer ignore-call */ 
473
              assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
473
    }
474
475
    public function testDeleteWithCondition()
476
    {
477
        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

477
        self::/** @scrutinizer ignore-call */ 
478
              assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = 3');
Loading history...
478
    }
479
480
    /**
481
     * The main use case for this generalized style of join is when a join condition
482
     * does not involve a foreign key relationship that is mapped to an entity relationship.
483
     */
484
    public function testImplicitJoinWithCartesianProductAndConditionInWhere()
485
    {
486
        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

486
        self::/** @scrutinizer ignore-call */ 
487
              assertValidDQL("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic");
Loading history...
487
    }
488
489
    public function testAllExpressionWithCorrelatedSubquery()
490
    {
491
        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

491
        self::/** @scrutinizer ignore-call */ 
492
              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...
492
    }
493
494
    public function testCustomJoinsAndWithKeywordSupported()
495
    {
496
        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

496
        self::/** @scrutinizer ignore-call */ 
497
              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...
497
    }
498
499
    public function testAnyExpressionWithCorrelatedSubquery()
500
    {
501
        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

501
        self::/** @scrutinizer ignore-call */ 
502
              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...
502
    }
503
504
    public function testSomeExpressionWithCorrelatedSubquery()
505
    {
506
        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

506
        self::/** @scrutinizer ignore-call */ 
507
              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...
507
    }
508
509
    public function testArithmeticExpressionWithoutParenthesisInWhereClause()
510
    {
511
        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

511
        self::/** @scrutinizer ignore-call */ 
512
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) + 1 > 10');
Loading history...
512
    }
513
514
    public function testMemberOfExpression()
515
    {
516
        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

516
        self::/** @scrutinizer ignore-call */ 
517
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers');
Loading history...
517
        //self::assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE 'Joe' MEMBER OF u.nicknames");
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
518
    }
519
520
    public function testSizeFunction()
521
    {
522
        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

522
        self::/** @scrutinizer ignore-call */ 
523
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1');
Loading history...
523
    }
524
525
    public function testEmptyCollectionComparisonExpression()
526
    {
527
        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

527
        self::/** @scrutinizer ignore-call */ 
528
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY');
Loading history...
528
    }
529
530
    public function testSingleValuedAssociationFieldInWhere()
531
    {
532
        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

532
        self::/** @scrutinizer ignore-call */ 
533
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
Loading history...
533
        self::assertValidDQL('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1');
534
    }
535
536
    public function testBooleanLiteralInWhere()
537
    {
538
        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

538
        self::/** @scrutinizer ignore-call */ 
539
              assertValidDQL('SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true');
Loading history...
539
    }
540
541
    public function testSubqueryInSelectExpression()
542
    {
543
        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

543
        self::/** @scrutinizer ignore-call */ 
544
              assertValidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
544
    }
545
546
    public function testUsageOfQComponentOutsideSubquery()
547
    {
548
        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

548
        self::/** @scrutinizer ignore-call */ 
549
              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...
549
    }
550
551
    public function testUnknownAbstractSchemaName()
552
    {
553
        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

553
        self::/** @scrutinizer ignore-call */ 
554
              assertInvalidDQL('SELECT u FROM UnknownClassName u');
Loading history...
554
    }
555
556
    public function testCorrectPartialObjectLoad()
557
    {
558
        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

558
        self::/** @scrutinizer ignore-call */ 
559
              assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
559
    }
560
561
    public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier()
562
    {
563
        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

563
        self::/** @scrutinizer ignore-call */ 
564
              assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
564
    }
565
566
    public function testScalarExpressionInSelect()
567
    {
568
        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

568
        self::/** @scrutinizer ignore-call */ 
569
              assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
569
    }
570
571
    public function testInputParameterInSelect()
572
    {
573
        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

573
        self::/** @scrutinizer ignore-call */ 
574
              assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
Loading history...
574
    }
575
576
    /**
577
     * @group DDC-1091
578
     */
579
    public function testCustomFunctionsReturningStringInStringPrimary()
580
    {
581
        $this->em->getConfiguration()->addCustomStringFunction('CC', Query\AST\Functions\ConcatFunction::class);
582
583
        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

583
        self::/** @scrutinizer ignore-call */ 
584
              assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true);
Loading history...
584
    }
585
586
    /**
587
     * @group DDC-505
588
     */
589
    public function testDQLKeywordInJoinIsAllowed()
590
    {
591
        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

591
        self::/** @scrutinizer ignore-call */ 
592
              assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g');
Loading history...
592
    }
593
594
    /**
595
     * @group DDC-505
596
     */
597
    public function testDQLKeywordInConditionIsAllowed()
598
    {
599
        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

599
        self::/** @scrutinizer ignore-call */ 
600
              assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0');
Loading history...
600
    }
601
602
    /* The exception is currently thrown in the SQLWalker, not earlier.
603
    public function testInverseSideSingleValuedAssociationPathNotAllowed()
604
    {
605
        self::assertInvalidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
606
    }
607
    */
608
609
    /**
610
     * @group DDC-617
611
     */
612
    public function testSelectOnlyNonRootEntityAlias()
613
    {
614
        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

614
        self::/** @scrutinizer ignore-call */ 
615
              assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g');
Loading history...
615
    }
616
617
    /**
618
     * @group DDC-1108
619
     */
620
    public function testInputParameterSingleChar()
621
    {
622
        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

622
        self::/** @scrutinizer ignore-call */ 
623
              assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q');
Loading history...
623
    }
624
625
    /**
626
     * @group DDC-1053
627
     */
628
    public function testGroupBy()
629
    {
630
        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

630
        self::/** @scrutinizer ignore-call */ 
631
              assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id');
Loading history...
631
    }
632
633
    /**
634
     * @group DDC-1053
635
     */
636
    public function testGroupByIdentificationVariable()
637
    {
638
        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

638
        self::/** @scrutinizer ignore-call */ 
639
              assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g');
Loading history...
639
    }
640
641
    /**
642
     * @group DDC-1053
643
     */
644
    public function testGroupByUnknownIdentificationVariable()
645
    {
646
        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

646
        self::/** @scrutinizer ignore-call */ 
647
              assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m');
Loading history...
647
    }
648
649
    /**
650
     * @group DDC-117
651
     */
652
    public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity()
653
    {
654
        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

654
        self::/** @scrutinizer ignore-call */ 
655
              assertValidDQL("SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0");
Loading history...
655
    }
656
657
    /**
658
     * @group DDC-117
659
     */
660
    public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity()
661
    {
662
        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

662
        self::/** @scrutinizer ignore-call */ 
663
              assertValidDQL("SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0");
Loading history...
663
    }
664
665
    public function testCaseSupportContainingNullIfExpression()
666
    {
667
        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

667
        self::/** @scrutinizer ignore-call */ 
668
              assertValidDQL("SELECT u.id, NULLIF(u.name, u.name) AS shouldBeNull FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
668
    }
669
670
    public function testCaseSupportContainingCoalesceExpression()
671
    {
672
        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

672
        self::/** @scrutinizer ignore-call */ 
673
              assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
673
    }
674
675
    /**
676
     * @group DDC-1858
677
     */
678
    public function testHavingSupportIsNullExpression()
679
    {
680
        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

680
        self::/** @scrutinizer ignore-call */ 
681
              assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL");
Loading history...
681
    }
682
683
    /**
684
     * @group DDC-3085
685
     */
686
    public function testHavingSupportResultVariableInNullComparisonExpression()
687
    {
688
        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

688
        self::/** @scrutinizer ignore-call */ 
689
              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...
689
    }
690
691
    /**
692
     * @group DDC-1858
693
     */
694
    public function testHavingSupportLikeExpression()
695
    {
696
        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

696
        self::/** @scrutinizer ignore-call */ 
697
              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...
697
    }
698
699
    /**
700
     * @group DDC-3018
701
     */
702
    public function testNewLiteralExpression()
703
    {
704
        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

704
        self::/** @scrutinizer ignore-call */ 
705
              assertValidDQL("SELECT new " . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', 1, true) FROM Doctrine\Tests\Models\CMS\CmsUser u");
Loading history...
705
    }
706
707
    /**
708
     * @group DDC-3075
709
     */
710
    public function testNewLiteralWithSubselectExpression()
711
    {
712
        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

712
        self::/** @scrutinizer ignore-call */ 
713
              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...
713
    }
714
}
715
716
/** @ORM\Entity */
717
class DQLKeywordsModelUser
718
{
719
    /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */
720
    private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
721
    /** @ORM\OneToOne(targetEntity="DQLKeywordsModelGroup") */
722
    private $group;
0 ignored issues
show
introduced by
The private property $group is not used, and could be removed.
Loading history...
723
}
724
725
/** @ORM\Entity */
726
class DQLKeywordsModelGroup
727
{
728
    /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */
729
    private $id;
730
    /** @ORM\Column */
731
    private $from;
0 ignored issues
show
introduced by
The private property $from is not used, and could be removed.
Loading history...
732
}
733
734
class DummyStruct
735
{
736
    public function __construct($id, $arg1, $arg2, $arg3)
0 ignored issues
show
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

736
    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...
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

736
    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 $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

736
    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

736
    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...
737
    {
738
    }
739
}
740