‪TYPO3CMS  10.4
TcaColumnsOverridesTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪TcaColumnsOverridesTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->subject = new ‪TcaColumnsOverrides();
35  }
36 
41  {
42  $input = [
43  'command' => 'new',
44  'tableName' => 'aTable',
45  'recordTypeValue' => 'foo',
46  'processedTca' => [
47  'columns' => [],
48  'types' => [
49  'foo' => [
50  'showitem' => [],
51  'columnsOverrides' => [],
52  ],
53  ],
54  ],
55  ];
56 
57  $expected = $input;
58  unset($expected['processedTca']['types']['foo']['columnsOverrides']);
59 
60  self::assertEquals($expected, $this->subject->addData($input));
61  }
62 
67  {
68  $input = [
69  'command' => 'new',
70  'tableName' => 'aTable',
71  'recordTypeValue' => 'foo',
72  'processedTca' => [
73  'columns' => [
74  'aField' => [
75  'aConfig' => 'aValue',
76  'anotherConfig' => 'anotherValue',
77  ],
78  ],
79  'types' => [
80  'foo' => [
81  'showitem' => [],
82  'columnsOverrides' => [
83  'aField' => [
84  'aConfig' => 'aDifferentValue',
85  ],
86  ],
87  ],
88  ],
89  ],
90  ];
91 
92  $expected = $input;
93  $expected['processedTca']['columns']['aField']['aConfig'] = 'aDifferentValue';
94  unset($expected['processedTca']['types']['foo']['columnsOverrides']);
95 
96  self::assertEquals($expected, $this->subject->addData($input));
97  }
98 
103  {
104  $input = [
105  'command' => 'new',
106  'tableName' => 'aTable',
107  'vanillaUid' => 12,
108  'databaseRow' => [
109  'uid' => 42,
110  ],
111  'recordTypeValue' => 'foo',
112  'processedTca' => [
113  'columns' => [
114  'aField' => [
115  'aConfig' => 'aValue'
116  ],
117  ],
118  'types' => [
119  'foo' => [
120  'showitem' => [],
121  'columnsOverrides' => [
122  'aField' => [
123  'config' => [
124  'default' => 'aDefault'
125  ]
126  ],
127  ],
128  ],
129  ],
130  ],
131  ];
132 
133  $expected = $input;
134  $expected['databaseRow']['aField'] = 'aDefault';
135  $expected['processedTca']['columns']['aField']['config']['default'] = 'aDefault';
136  unset($expected['processedTca']['types']['foo']['columnsOverrides']);
137 
138  self::assertEquals($expected, $this->subject->addData($input));
139  }
140 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\setUp
‪setUp()
Definition: TcaColumnsOverridesTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\$subject
‪TcaColumnsOverrides $subject
Definition: TcaColumnsOverridesTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest
Definition: TcaColumnsOverridesTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\addDataRemovesGivenColumnsOverrides
‪addDataRemovesGivenColumnsOverrides()
Definition: TcaColumnsOverridesTest.php:39
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\addDataMergesColumnsOverridesDefaultValueIntoDatabaseRow
‪addDataMergesColumnsOverridesDefaultValueIntoDatabaseRow()
Definition: TcaColumnsOverridesTest.php:101
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsOverrides
Definition: TcaColumnsOverrides.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\addDataMergesColumnsOverridesIntoColumns
‪addDataMergesColumnsOverridesIntoColumns()
Definition: TcaColumnsOverridesTest.php:65
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18