‪TYPO3CMS  ‪main
NamedPlaceholderPreparedStatementTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\ParameterType;
21 use PHPUnit\Framework\Attributes\Test;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
28 final class ‪NamedPlaceholderPreparedStatementTest extends FunctionalTestCase
29 {
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  $this->importCSVDataSet(__DIR__ . '/Fixtures/DataSet/queryBuilder_preparedStatement.csv');
34  }
35 
36  #[Test]
38  {
39  $this->expectExceptionObject(
41  );
42 
43  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
44  ->getQueryBuilderForTable('pages');
45  $queryBuilder->getRestrictions()
46  ->removeAll()
47  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
48 
49  $queryBuilder
50  ->select(...['*'])
51  ->from('pages')
52  ->where(
53  $queryBuilder->expr()->eq(
54  'pid',
55  $queryBuilder->createNamedParameter(10, ParameterType::INTEGER)
56  )
57  )
58  ->orderBy('sorting', 'ASC')
59  // add deterministic sort order as last sorting information, which many dbms
60  // and version does it by itself, but not all.
61  ->addOrderBy('uid', 'ASC')
62  ->prepare();
63  }
64 }
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest\throwsNamedParameterNotSupportedForPreparedStatementExceptionIfNamedPlacholderAreSetOnPrepare
‪throwsNamedParameterNotSupportedForPreparedStatementExceptionIfNamedPlacholderAreSetOnPrepare()
Definition: NamedPlaceholderPreparedStatementTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest\setUp
‪setUp()
Definition: NamedPlaceholderPreparedStatementTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest
Definition: NamedPlaceholderPreparedStatementTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder
Definition: NamedPlaceholderPreparedStatementTest.php:18
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Database\Query\NamedParameterNotSupportedForPreparedStatementException\new
‪static new(string $placeholderName)
Definition: NamedParameterNotSupportedForPreparedStatementException.php:22
‪TYPO3\CMS\Core\Database\Query\NamedParameterNotSupportedForPreparedStatementException
Definition: NamedParameterNotSupportedForPreparedStatementException.php:21