[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Preparations / TcaPreparationTest.php
1 <?php
2
3 namespace TYPO3\CMS\Core\Tests\Unit\Preparations;
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;
19 use TYPO3\CMS\Core\Database\Connection;
20 use TYPO3\CMS\Core\Database\ConnectionPool;
21 use TYPO3\CMS\Core\Preparations\TcaPreparation;
22 use TYPO3\CMS\Core\Utility\GeneralUtility;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24
25 /**
26 * Test case
27 */
28 class TcaPreparationTest extends UnitTestCase
29 {
30 public function prepareQuotingOfTableNamesAndColumnNamesDataProvider()
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
70 /**
71 * @test
72 * @dataProvider prepareQuotingOfTableNamesAndColumnNamesDataProvider
73 */
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 }