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