2 declare(strict_types = 1);
18 use Doctrine\DBAL\Platforms\AbstractPlatform;
19 use Doctrine\DBAL\Platforms\MySqlPlatform;
20 use Doctrine\DBAL\Platforms\OraclePlatform;
21 use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
22 use Doctrine\DBAL\Platforms\SqlitePlatform;
23 use Doctrine\DBAL\Platforms\SQLServerPlatform;
24 use Prophecy\Argument;
34 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
64 protected function setUp(): void
68 $this->concreteQueryBuilder = $this->prophesize(\Doctrine\DBAL\Query\QueryBuilder::class);
70 $this->connection = $this->prophesize(Connection::class);
71 $this->connection->getDatabasePlatform()->willReturn(
new MockPlatform());
74 $this->connection->reveal(),
76 $this->concreteQueryBuilder->reveal()
85 $this->connection->getExpressionBuilder()
87 ->willReturn(GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal()));
89 $this->subject->expr();
97 $this->concreteQueryBuilder->getType()
99 ->willReturn(\Doctrine\DBAL\Query\QueryBuilder::INSERT);
101 $this->subject->getType();
109 $this->concreteQueryBuilder->getState()
111 ->willReturn(\Doctrine\DBAL\Query\QueryBuilder::STATE_CLEAN);
113 $this->subject->getState();
121 $this->concreteQueryBuilder->getSQL()
123 ->willReturn(
'UPDATE aTable SET pid = 7');
124 $this->concreteQueryBuilder->getType()
127 $this->subject->getSQL();
135 $this->concreteQueryBuilder->setParameter(Argument::exact(
'aField'), Argument::exact(5), Argument::cetera())
137 ->willReturn($this->subject);
139 $this->subject->setParameter(
'aField', 5);
147 $this->concreteQueryBuilder->setParameters(Argument::exact([
'aField' =>
'aValue']), Argument::exact([]))
149 ->willReturn($this->subject);
151 $this->subject->setParameters([
'aField' =>
'aValue']);
159 $this->concreteQueryBuilder->getParameters()
161 ->willReturn([
'aField' =>
'aValue']);
163 $this->subject->getParameters();
171 $this->concreteQueryBuilder->getParameter(Argument::exact(
'aField'))
173 ->willReturn(
'aValue');
175 $this->subject->getParameter(
'aField');
183 $this->concreteQueryBuilder->getParameterTypes()
187 $this->subject->getParameterTypes();
195 $this->concreteQueryBuilder->getParameterType(Argument::exact(
'aField'))
199 $this->subject->getParameterType(
'aField');
207 $this->concreteQueryBuilder->setFirstResult(Argument::cetera())
209 ->willReturn($this->subject);
211 $this->subject->setFirstResult(1);
219 $this->concreteQueryBuilder->getFirstResult()
223 $this->subject->getFirstResult();
231 $this->concreteQueryBuilder->setMaxResults(Argument::cetera())
233 ->willReturn($this->subject);
235 $this->subject->setMaxResults(1);
243 $this->concreteQueryBuilder->getMaxResults()
247 $this->subject->getMaxResults();
255 $this->concreteQueryBuilder->add(Argument::exact(
'select'), Argument::exact(
'aField'), Argument::cetera())
257 ->willReturn($this->subject);
259 $this->subject->add(
'select',
'aField');
267 $this->concreteQueryBuilder->select(Argument::exact(
'COUNT(*)'))
269 ->willReturn($this->subject);
271 $this->subject->count(
'*');
279 $this->connection->quoteIdentifier(
'aField')
281 ->willReturnArgument(0);
282 $this->connection->quoteIdentifier(
'anotherField')
284 ->willReturnArgument(0);
285 $this->concreteQueryBuilder->select(Argument::exact(
'aField'), Argument::exact(
'anotherField'))
287 ->willReturn($this->subject);
289 $this->subject->select(
'aField',
'anotherField');
302 'tableName.fieldName' => [
303 'tableName.fieldName',
304 '"tableName"."fieldName"',
314 'fieldName AS anotherFieldName' => [
315 'fieldName AS anotherFieldName',
316 '"fieldName" AS "anotherFieldName"',
318 'tableName.fieldName AS anotherFieldName' => [
319 'tableName.fieldName AS anotherFieldName',
320 '"tableName"."fieldName" AS "anotherFieldName"',
322 'tableName.fieldName AS anotherTable.anotherFieldName' => [
323 'tableName.fieldName AS anotherTable.anotherFieldName',
324 '"tableName"."fieldName" AS "anotherTable"."anotherFieldName"',
326 'fieldName as anotherFieldName' => [
327 'fieldName as anotherFieldName',
328 '"fieldName" AS "anotherFieldName"',
330 'tableName.fieldName as anotherFieldName' => [
331 'tableName.fieldName as anotherFieldName',
332 '"tableName"."fieldName" AS "anotherFieldName"',
334 'tableName.fieldName as anotherTable.anotherFieldName' => [
335 'tableName.fieldName as anotherTable.anotherFieldName',
336 '"tableName"."fieldName" AS "anotherTable"."anotherFieldName"',
338 'fieldName aS anotherFieldName' => [
339 'fieldName aS anotherFieldName',
340 '"fieldName" AS "anotherFieldName"',
342 'tableName.fieldName aS anotherFieldName' => [
343 'tableName.fieldName aS anotherFieldName',
344 '"tableName"."fieldName" AS "anotherFieldName"',
346 'tableName.fieldName aS anotherTable.anotherFieldName' => [
347 'tableName.fieldName aS anotherTable.anotherFieldName',
348 '"tableName"."fieldName" AS "anotherTable"."anotherFieldName"',
361 $this->connection->quoteIdentifier(Argument::cetera())->will(
369 $this->assertSame([$expectedResult], $this->subject->quoteIdentifiersForSelect([$identifier]));
377 $this->expectException(\InvalidArgumentException::class);
378 $this->expectExceptionCode(1461170686);
380 $this->connection->quoteIdentifier(Argument::cetera())->will(
387 $this->subject->quoteIdentifiersForSelect([
'aField AS anotherField,someField AS someThing']);
395 $this->connection->quoteIdentifier(
'aField')
397 ->willReturnArgument(0);
398 $this->connection->quoteIdentifier(
'*')
399 ->shouldNotBeCalled();
400 $this->concreteQueryBuilder->select(Argument::exact(
'aField'), Argument::exact(
'*'))
402 ->willReturn($this->subject);
404 $this->subject->select(
'aField',
'*');
412 $this->connection->quoteIdentifier(
'aField')
414 ->willReturnArgument(0);
415 $this->connection->quoteIdentifier(
'anotherField')
417 ->willReturnArgument(0);
418 $this->concreteQueryBuilder->addSelect(Argument::exact(
'aField'), Argument::exact(
'anotherField'))
420 ->willReturn($this->subject);
422 $this->subject->addSelect(
'aField',
'anotherField');
430 $this->connection->quoteIdentifier(
'aField')
432 ->willReturnArgument(0);
433 $this->connection->quoteIdentifier(
'*')
434 ->shouldNotBeCalled();
435 $this->concreteQueryBuilder->addSelect(Argument::exact(
'aField'), Argument::exact(
'*'))
437 ->willReturn($this->subject);
439 $this->subject->addSelect(
'aField',
'*');
447 $this->connection->quoteIdentifier(Argument::cetera())
448 ->shouldNotBeCalled();
449 $this->concreteQueryBuilder->select(Argument::exact(
'MAX(aField) AS anAlias'))
451 ->willReturn($this->subject);
453 $this->subject->selectLiteral(
'MAX(aField) AS anAlias');
461 $this->connection->quoteIdentifier(Argument::cetera())
462 ->shouldNotBeCalled();
463 $this->concreteQueryBuilder->addSelect(Argument::exact(
'MAX(aField) AS anAlias'))
465 ->willReturn($this->subject);
467 $this->subject->addSelectLiteral(
'MAX(aField) AS anAlias');
476 $this->connection->quoteIdentifier(
'aTable')
478 ->willReturnArgument(0);
479 $this->concreteQueryBuilder->delete(Argument::exact(
'aTable'), Argument::cetera())
481 ->willReturn($this->subject);
483 $this->subject->delete(
'aTable');
492 $this->connection->quoteIdentifier(
'aTable')
494 ->willReturnArgument(0);
495 $this->concreteQueryBuilder->update(Argument::exact(
'aTable'), Argument::cetera())
497 ->willReturn($this->subject);
499 $this->subject->update(
'aTable');
507 $this->connection->quoteIdentifier(
'aTable')
509 ->willReturnArgument(0);
510 $this->concreteQueryBuilder->insert(Argument::exact(
'aTable'))
512 ->willReturn($this->subject);
514 $this->subject->insert(
'aTable');
523 $this->connection->quoteIdentifier(
'aTable')
525 ->willReturnArgument(0);
526 $this->concreteQueryBuilder->from(Argument::exact(
'aTable'), Argument::cetera())
528 ->willReturn($this->subject);
530 $this->subject->from(
'aTable');
538 $this->connection->quoteIdentifier(
'fromAlias')
540 ->willReturnArgument(0);
541 $this->connection->quoteIdentifier(
'join')
543 ->willReturnArgument(0);
544 $this->connection->quoteIdentifier(
'alias')
546 ->willReturnArgument(0);
547 $this->concreteQueryBuilder->innerJoin(
'fromAlias',
'join',
'alias',
null)
549 ->willReturn($this->subject);
551 $this->subject->join(
'fromAlias',
'join',
'alias');
559 $this->connection->quoteIdentifier(
'fromAlias')
561 ->willReturnArgument(0);
562 $this->connection->quoteIdentifier(
'join')
564 ->willReturnArgument(0);
565 $this->connection->quoteIdentifier(
'alias')
567 ->willReturnArgument(0);
568 $this->concreteQueryBuilder->innerJoin(
'fromAlias',
'join',
'alias',
null)
570 ->willReturn($this->subject);
572 $this->subject->innerJoin(
'fromAlias',
'join',
'alias');
580 $this->connection->quoteIdentifier(
'fromAlias')
582 ->willReturnArgument(0);
583 $this->connection->quoteIdentifier(
'join')
585 ->willReturnArgument(0);
586 $this->connection->quoteIdentifier(
'alias')
588 ->willReturnArgument(0);
589 $this->concreteQueryBuilder->leftJoin(
'fromAlias',
'join',
'alias',
null)
591 ->willReturn($this->subject);
593 $this->subject->leftJoin(
'fromAlias',
'join',
'alias');
601 $this->connection->quoteIdentifier(
'fromAlias')
603 ->willReturnArgument(0);
604 $this->connection->quoteIdentifier(
'join')
606 ->willReturnArgument(0);
607 $this->connection->quoteIdentifier(
'alias')
609 ->willReturnArgument(0);
610 $this->concreteQueryBuilder->rightJoin(
'fromAlias',
'join',
'alias',
null)
612 ->willReturn($this->subject);
614 $this->subject->rightJoin(
'fromAlias',
'join',
'alias');
622 $this->connection->quoteIdentifier(
'aField')
624 ->willReturnArgument(0);
625 $this->concreteQueryBuilder->createNamedParameter(
'aValue', Argument::cetera())
627 ->willReturn(
':dcValue1');
628 $this->concreteQueryBuilder->set(
'aField',
':dcValue1')
630 ->willReturn($this->subject);
632 $this->subject->set(
'aField',
'aValue');
640 $this->connection->quoteIdentifier(
'aField')
642 ->willReturnArgument(0);
643 $this->concreteQueryBuilder->createNamedParameter(Argument::cetera())->shouldNotBeCalled();
644 $this->concreteQueryBuilder->set(
'aField',
'aValue')
646 ->willReturn($this->subject);
648 $this->subject->set(
'aField',
'aValue',
false);
656 $this->concreteQueryBuilder->where(
'uid=1',
'type=9')
658 ->willReturn($this->subject);
660 $this->subject->where(
'uid=1',
'type=9');
668 $this->concreteQueryBuilder->andWhere(
'uid=1',
'type=9')
670 ->willReturn($this->subject);
672 $this->subject->andWhere(
'uid=1',
'type=9');
680 $this->concreteQueryBuilder->orWhere(
'uid=1',
'type=9')
682 ->willReturn($this->subject);
684 $this->subject->orWhere(
'uid=1',
'type=9');
692 $this->connection->quoteIdentifiers([
'aField',
'anotherField'])
694 ->willReturnArgument(0);
695 $this->concreteQueryBuilder->groupBy(
'aField',
'anotherField')
697 ->willReturn($this->subject);
699 $this->subject->groupBy(
'aField',
'anotherField');
707 $this->connection->quoteIdentifiers([
'aField',
'anotherField'])
709 ->willReturnArgument(0);
710 $this->concreteQueryBuilder->addGroupBy(
'aField',
'anotherField')
712 ->willReturn($this->subject);
714 $this->subject->addGroupBy(
'aField',
'anotherField');
722 $this->connection->quoteIdentifier(
'aField')
724 ->willReturnArgument(0);
725 $this->concreteQueryBuilder->createNamedParameter(
'aValue', Argument::cetera())
727 ->willReturn(
':dcValue1');
728 $this->concreteQueryBuilder->setValue(
'aField',
':dcValue1')
730 ->willReturn($this->subject);
732 $this->subject->setValue(
'aField',
'aValue');
740 $this->connection->quoteIdentifier(
'aField')
742 ->willReturnArgument(0);
743 $this->concreteQueryBuilder->setValue(
'aField',
'aValue')
745 ->willReturn($this->subject);
747 $this->subject->setValue(
'aField',
'aValue',
false);
755 $this->connection->quoteColumnValuePairs([
'aField' =>
':dcValue1',
'aValue' =>
':dcValue2'])
757 ->willReturnArgument(0);
758 $this->concreteQueryBuilder->createNamedParameter(1, Argument::cetera())
760 ->willReturn(
':dcValue1');
761 $this->concreteQueryBuilder->createNamedParameter(2, Argument::cetera())
763 ->willReturn(
':dcValue2');
764 $this->concreteQueryBuilder->values([
'aField' =>
':dcValue1',
'aValue' =>
':dcValue2'])
766 ->willReturn($this->subject);
768 $this->subject->values([
'aField' => 1,
'aValue' => 2]);
776 $this->connection->quoteColumnValuePairs([
'aField' => 1,
'aValue' => 2])
778 ->willReturnArgument(0);
779 $this->concreteQueryBuilder->values([
'aField' => 1,
'aValue' => 2])
781 ->willReturn($this->subject);
783 $this->subject->values([
'aField' => 1,
'aValue' => 2],
false);
791 $this->concreteQueryBuilder->having(
'uid=1',
'type=9')
793 ->willReturn($this->subject);
795 $this->subject->having(
'uid=1',
'type=9');
803 $this->concreteQueryBuilder->andHaving(
'uid=1',
'type=9')
805 ->willReturn($this->subject);
807 $this->subject->andHaving(
'uid=1',
'type=9');
815 $this->concreteQueryBuilder->orHaving(
'uid=1',
'type=9')
817 ->willReturn($this->subject);
819 $this->subject->orHaving(
'uid=1',
'type=9');
827 $this->connection->quoteIdentifier(
'aField')
829 ->willReturnArgument(0);
830 $this->concreteQueryBuilder->orderBy(
'aField',
null)
832 ->willReturn($this->subject);
834 $this->subject->orderBy(
'aField');
842 $this->connection->quoteIdentifier(
'aField')
844 ->willReturnArgument(0);
845 $this->concreteQueryBuilder->addOrderBy(
'aField',
'DESC')
847 ->willReturn($this->subject);
849 $this->subject->addOrderBy(
'aField',
'DESC');
857 $this->concreteQueryBuilder->getQueryPart(
'from')
859 ->willReturn(
'aTable');
861 $this->subject->getQueryPart(
'from');
869 $this->concreteQueryBuilder->getQueryParts()
873 $this->subject->getQueryParts();
881 $this->concreteQueryBuilder->resetQueryParts([
'select',
'from'])
883 ->willReturn($this->subject);
885 $this->subject->resetQueryParts([
'select',
'from']);
893 $this->concreteQueryBuilder->resetQueryPart(
'select')
895 ->willReturn($this->subject);
897 $this->subject->resetQueryPart(
'select');
905 $this->concreteQueryBuilder->createNamedParameter(5, Argument::cetera())
907 ->willReturn(
':dcValue1');
909 $this->subject->createNamedParameter(5);
917 $this->concreteQueryBuilder->createPositionalParameter(5, Argument::cetera())
921 $this->subject->createPositionalParameter(5);
930 'tstamp' =>
'tstamp',
931 'versioningWS' =>
true,
932 'delete' =>
'deleted',
933 'crdate' =>
'crdate',
935 'disabled' =>
'hidden',
939 $this->connection->quoteIdentifier(Argument::cetera())
940 ->willReturnArgument(0);
941 $this->connection->quoteIdentifiers(Argument::cetera())
942 ->willReturnArgument(0);
944 $connectionBuilder = GeneralUtility::makeInstance(
945 \Doctrine\DBAL\Query\QueryBuilder::class,
946 $this->connection->reveal()
949 $expressionBuilder = GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal());
950 $this->connection->getExpressionBuilder()
951 ->willReturn($expressionBuilder);
953 $subject = GeneralUtility::makeInstance(
955 $this->connection->reveal(),
964 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND ((pages.deleted = 0) AND (pages.hidden = 0))';
965 $this->connection->executeQuery($expectedSQL, Argument::cetera())
977 'tstamp' =>
'tstamp',
978 'versioningWS' =>
true,
979 'delete' =>
'deleted',
980 'crdate' =>
'crdate',
982 'disabled' =>
'hidden',
986 $this->connection->quoteIdentifier(Argument::cetera())
987 ->willReturnArgument(0);
988 $this->connection->quoteIdentifiers(Argument::cetera())
989 ->willReturnArgument(0);
991 $connectionBuilder = GeneralUtility::makeInstance(
992 \Doctrine\DBAL\Query\QueryBuilder::class,
993 $this->connection->reveal()
996 $expressionBuilder = GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal());
997 $this->connection->getExpressionBuilder()
998 ->willReturn($expressionBuilder);
1000 $subject = GeneralUtility::makeInstance(
1001 QueryBuilder::class,
1002 $this->connection->reveal(),
1011 $expectedSQL =
'SELECT COUNT(uid) FROM pages WHERE (uid=1) AND ((pages.deleted = 0) AND (pages.hidden = 0))';
1012 $this->connection->executeQuery($expectedSQL, Argument::cetera())
1024 'tstamp' =>
'tstamp',
1025 'versioningWS' =>
true,
1026 'delete' =>
'deleted',
1027 'crdate' =>
'crdate',
1028 'enablecolumns' => [
1029 'disabled' =>
'hidden',
1033 $this->connection->quoteIdentifier(Argument::cetera())
1034 ->willReturnArgument(0);
1035 $this->connection->quoteIdentifiers(Argument::cetera())
1036 ->willReturnArgument(0);
1037 $this->connection->getExpressionBuilder()
1038 ->willReturn(GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal()));
1041 \Doctrine\DBAL\Query\QueryBuilder::class,
1042 $this->connection->reveal()
1045 $subject = GeneralUtility::makeInstance(
1046 QueryBuilder::class,
1047 $this->connection->reveal(),
1056 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND ((pages.deleted = 0) AND (pages.hidden = 0))';
1061 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND (pages.deleted = 0)';
1071 'tstamp' =>
'tstamp',
1072 'versioningWS' =>
true,
1073 'delete' =>
'deleted',
1074 'crdate' =>
'crdate',
1075 'enablecolumns' => [
1076 'disabled' =>
'hidden',
1080 $this->connection->quoteIdentifier(Argument::cetera())
1081 ->willReturnArgument(0);
1082 $this->connection->quoteIdentifiers(Argument::cetera())
1083 ->willReturnArgument(0);
1084 $this->connection->getExpressionBuilder()
1085 ->willReturn(GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal()));
1088 \Doctrine\DBAL\Query\QueryBuilder::class,
1089 $this->connection->reveal()
1092 $subject = GeneralUtility::makeInstance(
1093 QueryBuilder::class,
1094 $this->connection->reveal(),
1105 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND (pages.deleted = 0)';
1106 $this->connection->executeQuery($expectedSQL, Argument::cetera())
1113 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND ((pages.deleted = 0) AND (pages.hidden = 0))';
1114 $this->connection->executeQuery($expectedSQL, Argument::cetera())
1125 $this->concreteQueryBuilder->getQueryPart(
'from')
1129 'table' =>
'aTable',
1132 $this->concreteQueryBuilder->getQueryPart(
'join')
1137 'joinType' =>
'inner',
1138 'joinTable' =>
'aTable',
1139 'joinAlias' =>
'aTable_alias'
1143 $result = $this->callInaccessibleMethod($this->subject,
'getQueriedTables');
1146 'aTable' =>
'aTable',
1147 'aTable_alias' =>
'aTable'
1149 $this->assertEquals($expected, $result);
1159 'platform' => MySqlPlatform::class,
1161 'input' =>
'`anIdentifier`',
1162 'expected' =>
'anIdentifier',
1164 'mysql with spaces' => [
1165 'platform' => MySqlPlatform::class,
1167 'input' =>
' `anIdentifier` ',
1168 'expected' =>
'anIdentifier',
1171 'platform' => PostgreSqlPlatform::class,
1173 'input' =>
'"anIdentifier"',
1174 'expected' =>
'anIdentifier',
1177 'platform' => SQLServerPlatform::class,
1179 'input' =>
'[anIdentifier]',
1180 'expected' =>
'anIdentifier',
1195 $connectionProphecy = $this->prophesize(Connection::class);
1196 $databasePlatformProphecy = $this->prophesize(
$platform);
1197 $databasePlatformProphecy->getIdentifierQuoteCharacter()->willReturn($quoteChar);
1198 $connectionProphecy->getDatabasePlatform()->willReturn($databasePlatformProphecy);
1199 $subject = GeneralUtility::makeInstance(QueryBuilder::class, $connectionProphecy->reveal());
1200 $result = $this->callInaccessibleMethod(
$subject,
'unquoteSingleIdentifier', $input);
1201 $this->assertEquals($expected, $result);
1210 self::assertNotSame($this->subject->getConcreteQueryBuilder(), $clonedQueryBuilder->getConcreteQueryBuilder());
1219 'tstamp' =>
'tstamp',
1220 'versioningWS' =>
true,
1221 'delete' =>
'deleted',
1222 'crdate' =>
'crdate',
1223 'enablecolumns' => [
1224 'disabled' =>
'hidden',
1228 $this->connection->quoteIdentifier(Argument::cetera())
1229 ->willReturnArgument(0);
1230 $this->connection->quoteIdentifiers(Argument::cetera())
1231 ->willReturnArgument(0);
1232 $this->connection->getExpressionBuilder()
1233 ->willReturn(GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal()));
1236 \Doctrine\DBAL\Query\QueryBuilder::class,
1237 $this->connection->reveal()
1240 $subject = GeneralUtility::makeInstance(
1241 QueryBuilder::class,
1242 $this->connection->reveal(),
1251 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND ((pages.deleted = 0) AND (pages.hidden = 0))';
1256 $this->assertSame($expectedSQL, $clonedQueryBuilder->getSQL());
1259 $clonedQueryBuilder->count(
'*');
1260 $expectedCountSQL =
'SELECT COUNT(*) FROM pages WHERE (uid=1) AND ((pages.deleted = 0) AND (pages.hidden = 0))';
1261 $this->assertSame($expectedCountSQL, $clonedQueryBuilder->getSQL());
1268 $expectedSQL =
'SELECT * FROM pages WHERE (uid=1) AND (pages.deleted = 0)';
1271 $this->assertSame($expectedCountSQL, $clonedQueryBuilder->getSQL());
1279 $restrictionClass = get_class($this->prophesize(QueryRestrictionInterface::class)->reveal());
1281 $this->connection->reveal(),
1283 $this->concreteQueryBuilder->reveal(),
1285 $restrictionClass => [],
1289 $container = $this->prophesize(AbstractRestrictionContainer::class);
1290 $container->add(
new $restrictionClass())->shouldBeCalled();
1292 $queryBuilder->setRestrictions($container->reveal());
1300 $restrictionClass = get_class($this->prophesize(QueryRestrictionInterface::class)->reveal());
1301 $GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'additionalQueryRestrictions'][$restrictionClass] = [];
1303 $this->connection->reveal(),
1305 $this->concreteQueryBuilder->reveal()
1308 $container = $this->prophesize(AbstractRestrictionContainer::class);
1309 $container->add(
new $restrictionClass())->shouldBeCalled();
1311 $queryBuilder->setRestrictions($container->reveal());
1319 $restrictionClass = get_class($this->prophesize(QueryRestrictionInterface::class)->reveal());
1320 $GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'additionalQueryRestrictions'][$restrictionClass] = [
'disabled' =>
true];
1322 $this->connection->reveal(),
1324 $this->concreteQueryBuilder->reveal()
1327 $container = $this->prophesize(AbstractRestrictionContainer::class);
1328 $container->add(
new $restrictionClass())->shouldNotBeCalled();
1330 $queryBuilder->setRestrictions($container->reveal());
1338 $restrictionClass = get_class($this->prophesize(QueryRestrictionInterface::class)->reveal());
1340 $this->connection->reveal(),
1342 $this->concreteQueryBuilder->reveal(),
1344 $restrictionClass => [],
1348 $container = $this->prophesize(DefaultRestrictionContainer::class);
1349 $container->add(
new $restrictionClass())->shouldBeCalled();
1350 GeneralUtility::addInstance(DefaultRestrictionContainer::class, $container->reveal());
1352 $queryBuilder->resetRestrictions();
1358 'Test cast for MySqlPlatform' => [
1359 new MySqlPlatform(),
1360 'CONVERT(aField, CHAR)'
1362 'Test cast for PostgreSqlPlatform' => [
1363 new PostgreSqlPlatform(),
1366 'Test cast for SqlitePlatform' => [
1367 new SqlitePlatform(),
1368 'CAST(aField as TEXT)'
1370 'Test cast for SQLServerPlatform' => [
1371 new SQLServerPlatform(),
1372 'CAST(aField as VARCHAR)'
1374 'Test cast for OraclePlatform' => [
1375 new OraclePlatform(),
1376 'CAST(aField as VARCHAR)'
1390 $this->connection->quoteIdentifier(
'aField')
1392 ->willReturnArgument(0);
1394 $this->connection->getDatabasePlatform()->willReturn(
$platform);
1401 $this->connection->quoteIdentifier(
'aField')->shouldHaveBeenCalled();
1402 self::assertSame($expectation, $result);