‪TYPO3CMS  11.5
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;
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 class ‪NamedPlaceholderPreparedStatementTest extends FunctionalTestCase
28 {
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32  $this->withDatabaseSnapshot(function () {
33  $this->‪setUpDatabase();
34  });
35  }
36 
37  protected function ‪setUpDatabase(): void
38  {
39  $this->importCSVDataSet(__DIR__ . '/Fixtures/DataSet/queryBuilder_preparedStatement.csv');
40  }
41 
46  {
47  $this->expectExceptionObject(
49  );
50 
51  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
52  ->getQueryBuilderForTable('pages');
53  $queryBuilder->getRestrictions()
54  ->removeAll()
55  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
56 
57  $queryBuilder
58  ->select(...['*'])
59  ->from('pages')
60  ->where(
61  $queryBuilder->expr()->eq(
62  'pid',
63  $queryBuilder->createNamedParameter(10, ParameterType::INTEGER)
64  )
65  )
66  ->orderBy('sorting', 'ASC')
67  // add deterministic sort order as last sorting information, which many dbms
68  // and version does it by itself, but not all.
69  ->addOrderBy('uid', 'ASC')
70  ->prepare();
71  }
72 }
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest\throwsNamedParameterNotSupportedForPreparedStatementExceptionIfNamedPlacholderAreSetOnPrepare
‪throwsNamedParameterNotSupportedForPreparedStatementExceptionIfNamedPlacholderAreSetOnPrepare()
Definition: NamedPlaceholderPreparedStatementTest.php:45
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest\setUp
‪setUp()
Definition: NamedPlaceholderPreparedStatementTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest
Definition: NamedPlaceholderPreparedStatementTest.php:28
‪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:50
‪TYPO3\CMS\Core\Tests\Functional\Database\Query\QueryBuilder\NamedPlaceholderPreparedStatementTest\setUpDatabase
‪setUpDatabase()
Definition: NamedPlaceholderPreparedStatementTest.php:37
‪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