2 declare(strict_types = 1);
19 use Prophecy\Argument;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
37 'unprefixed input' => [
'1=1',
'1=1'],
38 'leading/trailing whitespace is removed' => [
' 1=1 ',
'1=1'],
39 'AND' => [
'AND 1=1',
'1=1'],
40 'AND with leading space' => [
' AND 1=1',
'1=1'],
41 'AND with mixed whitespace' => [
' AND 1<>1',
'1<>1'],
42 'AND with opening bracket' => [
'AND (1=1)',
'(1=1)'],
43 'AND without whitespace before bracket' => [
'AND(1=1)',
'(1=1)'],
44 'AND within input' => [
'1=1 AND 2=2',
'1=1 AND 2=2'],
45 'OR' => [
'OR 1=1',
'1=1'],
46 'OR with leading space' => [
' OR 1=1',
'1=1'],
47 'OR with mixed whitespace' => [
' OR 1<>1',
'1<>1'],
48 'OR with opening bracket' => [
'OR (1=1)',
'(1=1)'],
49 'OR without whitespace before bracket' => [
'OR(1=1)',
'(1=1)'],
50 'OR within input' => [
'1=1 OR 2=2',
'1=1 OR 2=2'],
83 'single field with leading whitespace' => [
89 'prefixed single field' => [
95 'prefixed single field with leading whitespace' => [
101 'single field with direction' => [
107 'multiple fields' => [
108 'aField,anotherField, aThirdField',
111 [
'anotherField',
null],
112 [
'aThirdField',
null]
115 'multiple fields with direction' => [
116 'aField ASC,anotherField, aThirdField DESC',
119 [
'anotherField',
null],
120 [
'aThirdField',
'DESC']
123 'prefixed multiple fields with direction' => [
124 'ORDER BY aField ASC,anotherField, aThirdField DESC',
127 [
'anotherField',
null],
128 [
'aThirdField',
'DESC']
131 'with table prefix' => [
132 'ORDER BY be_groups.title',
134 [
'be_groups.title',
null]
165 'single table with leading whitespace' => [
171 'prefixed single table' => [
177 'prefixed single table with leading whitespace' => [
183 'single table with alias' => [
189 'multiple tables' => [
190 'aTable,anotherTable, aThirdTable',
193 [
'anotherTable',
null],
194 [
'aThirdTable',
null]
197 'multiple tables with aliases' => [
198 'aTable a,anotherTable, aThirdTable AS c',
201 [
'anotherTable',
null],
205 'prefixed multiple tables with aliases' => [
206 'FROM aTable a,anotherTable, aThirdTable AS c',
209 [
'anotherTable',
null],
239 'single field with leading whitespace' => [
243 'prefixed single field' => [
247 'prefixed single field with leading whitespace' => [
251 'multiple fields' => [
252 'aField,anotherField, aThirdField',
253 [
'aField',
'anotherField',
'aThirdField']
255 'prefixed multiple fields' => [
256 'GROUP BY aField,anotherField, aThirdField',
257 [
'aField',
'anotherField',
'aThirdField']
259 'with table prefix' => [
260 'GROUP BY be_groups.title',
285 'unquoted tableName' => [
286 'aTable ON aTable.uid = anotherTable.uid_foreign',
288 'tableName' =>
'aTable',
289 'tableAlias' =>
'aTable',
290 'joinCondition' =>
'aTable.uid = anotherTable.uid_foreign'
293 'quoted tableName' => [
294 '`aTable` ON aTable.uid = anotherTable.uid_foreign',
296 'tableName' =>
'aTable',
297 'tableAlias' =>
'aTable',
298 'joinCondition' =>
'aTable.uid = anotherTable.uid_foreign'
301 'quoted tableName with alias' => [
302 '`aTable` a ON a.uid = anotherTable.uid_foreign',
304 'tableName' =>
'aTable',
306 'joinCondition' =>
'a.uid = anotherTable.uid_foreign'
309 'quoted tableName with quoted alias' => [
310 '`aTable` `a` ON a.uid = anotherTable.uid_foreign',
312 'tableName' =>
'aTable',
314 'joinCondition' =>
'a.uid = anotherTable.uid_foreign'
317 'quoted tableName with AS alias' => [
318 '`aTable` AS anAlias ON anAlias.uid = anotherTable.uid_foreign',
320 'tableName' =>
'aTable',
321 'tableAlias' =>
'anAlias',
322 'joinCondition' =>
'anAlias.uid = anotherTable.uid_foreign'
325 'quoted tableName with AS quoted alias' => [
326 '`aTable` AS `anAlias` ON anAlias.uid = anotherTable.uid_foreign',
328 'tableName' =>
'aTable',
329 'tableAlias' =>
'anAlias',
330 'joinCondition' =>
'anAlias.uid = anotherTable.uid_foreign'
333 'unquoted tableName with AS quoted alias' => [
334 'aTable AS `anAlias` ON anAlias.uid = anotherTable.uid_foreign',
336 'tableName' =>
'aTable',
337 'tableAlias' =>
'anAlias',
338 'joinCondition' =>
'anAlias.uid = anotherTable.uid_foreign'
363 'no marked identifiers' => [
367 'single fieldname' => [
371 'tablename and fieldname' => [
372 '{#tt_content.colPos}=0',
373 '"tt_content"."colPos"=0',
375 'multiple fieldnames' => [
376 '{#colPos}={#aField}',
390 $connectionProphet = $this->prophesize(Connection::class);
391 $connectionProphet->quoteIdentifier(Argument::cetera())->will(
function (
$args) {
393 function ($identifier) {
394 return '"' . $identifier .
'"';
399 return implode(
'.', $parts);