‪TYPO3CMS  9.5
TcaPreparationTest.php
Go to the documentation of this file.
1 <?php
2 
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 
18 use Prophecy\Argument;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪TcaPreparationTest extends UnitTestCase
29 {
31  {
32  return [
33  [
34  [
35  'aTable' => [
36  'columns' => [
37  'foo' => [
38  'config' => [
39  'type' => 'inline',
40  'foreign_table_where' => 'AND {#tt_content}.{#CType} IN (\'text\',\'textpic\',\'textmedia\') ORDER BY {#tt_content}.{#CType} ASC',
41  'MM_table_where' => 'AND {#uid_local} = ###REC_FIELD_category###',
42  'search' => [
43  'andWhere' => '{#CType}=\'text\' OR {#CType}=\'textpic\' OR {#CType}=\'textmedia\' AND {#title}=\'foo\'',
44  ],
45  ],
46  ],
47  ],
48  ],
49  ],
50  [
51  'aTable' => [
52  'columns' => [
53  'foo' => [
54  'config' => [
55  'type' => 'inline',
56  'foreign_table_where' => 'AND `tt_content`.`CType` IN (\'text\',\'textpic\',\'textmedia\') ORDER BY `tt_content`.`CType` ASC',
57  'MM_table_where' => 'AND `uid_local` = ###REC_FIELD_category###',
58  'search' => [
59  'andWhere' => '`CType`=\'text\' OR `CType`=\'textpic\' OR `CType`=\'textmedia\' AND `title`=\'foo\'',
60  ],
61  ],
62  ],
63  ],
64  ],
65  ],
66  ],
67  ];
68  }
69 
74  public function ‪prepareQuotingOfTableNamesAndColumnNames(array $input, array $expected)
75  {
76  $connection = $this->prophesize(Connection::class);
77  $connection->quoteIdentifier('tt_content')->willReturn('`tt_content`');
78  $connection->quoteIdentifier('CType')->willReturn('`CType`');
79  $connection->quoteIdentifier('uid_local')->willReturn('`uid_local`');
80  $connection->quoteIdentifier('title')->willReturn('`title`');
81  $connectionPool = $this->prophesize(ConnectionPool::class);
82  $connectionPool->getConnectionForTable(Argument::any())->willReturn($connection->reveal());
83  GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
84  $subject = new ‪TcaPreparation();
85  $this->assertEquals($expected, $subject->prepare($input));
86  }
87 }
‪TYPO3\CMS\Core\Tests\Unit\Preparations
Definition: TcaPreparationTest.php:3
‪TYPO3\CMS\Core\Tests\Unit\Preparations\TcaPreparationTest\prepareQuotingOfTableNamesAndColumnNamesDataProvider
‪prepareQuotingOfTableNamesAndColumnNamesDataProvider()
Definition: TcaPreparationTest.php:30
‪TYPO3\CMS\Core\Preparations\TcaPreparation
Definition: TcaPreparation.php:28
‪TYPO3\CMS\Core\Tests\Unit\Preparations\TcaPreparationTest\prepareQuotingOfTableNamesAndColumnNames
‪prepareQuotingOfTableNamesAndColumnNames(array $input, array $expected)
Definition: TcaPreparationTest.php:74
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:31
‪TYPO3\CMS\Core\Tests\Unit\Preparations\TcaPreparationTest
Definition: TcaPreparationTest.php:29
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45