[BUGFIX] Notice free FormEngine testing
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / TcaColumnsProcessCommonTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessCommon;
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19
20 /**
21 * Test case
22 */
23 class TcaColumnsProcessCommonTest extends UnitTestCase
24 {
25 /**
26 * @test
27 */
28 public function addDataRegistersOrigUidColumn()
29 {
30 $input = [
31 'recordTypeValue' => 'aType',
32 'columnsToProcess' => [],
33 'processedTca' => [
34 'ctrl' => [
35 'origUid' => 't3_origuid'
36 ]
37 ]
38 ];
39
40 $expected = $input;
41 $expected['columnsToProcess'] = ['t3_origuid'];
42 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
43 }
44
45 /**
46 * @test
47 */
48 public function addDataRegistersRecordTypeColumn()
49 {
50 $input = [
51 'recordTypeValue' => 'aType',
52 'columnsToProcess' => [],
53 'processedTca' => [
54 'ctrl' => [
55 'type' => 'doktype'
56 ]
57 ]
58 ];
59
60 $expected = $input;
61 $expected['columnsToProcess'] = ['doktype'];
62 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
63 }
64
65 /**
66 * @test
67 */
68 public function addDataRegistersRecordTypeRelationColumn()
69 {
70 $input = [
71 'recordTypeValue' => 'aType',
72 'columnsToProcess' => [],
73 'processedTca' => [
74 'ctrl' => [
75 'type' => 'relation_field:foreign_type_field'
76 ]
77 ]
78 ];
79
80 $expected = $input;
81 $expected['columnsToProcess'] = ['relation_field'];
82 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
83 }
84
85 /**
86 * @test
87 */
88 public function addDataRegistersLanguageFieldColumn()
89 {
90 $input = [
91 'recordTypeValue' => 'aType',
92 'columnsToProcess' => [],
93 'processedTca' => [
94 'ctrl' => [
95 'languageField' => 'sys_language_uid'
96 ]
97 ]
98 ];
99
100 $expected = $input;
101 $expected['columnsToProcess'] = ['sys_language_uid'];
102 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
103 }
104
105 /**
106 * @test
107 */
108 public function addDataRegistersTransOrigPointerColumn()
109 {
110 $input = [
111 'recordTypeValue' => 'aType',
112 'columnsToProcess' => [],
113 'processedTca' => [
114 'ctrl' => [
115 'transOrigPointerField' => 'l10n_parent'
116 ]
117 ]
118 ];
119
120 $expected = $input;
121 $expected['columnsToProcess'] = ['l10n_parent'];
122 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
123 }
124
125 /**
126 * @test
127 */
128 public function addDataRegistersTransOrigDiffSourceColumn()
129 {
130 $input = [
131 'recordTypeValue' => 'aType',
132 'columnsToProcess' => [],
133 'processedTca' => [
134 'ctrl' => [
135 'transOrigDiffSourceField' => 'l18n_diffsource'
136 ]
137 ]
138 ];
139
140 $expected = $input;
141 $expected['columnsToProcess'] = ['l18n_diffsource'];
142 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
143 }
144
145 /**
146 * @test
147 */
148 public function addDataRegistersSingleSubtypesAddlistFields()
149 {
150 $input = [
151 'recordTypeValue' => 'list',
152 'columnsToProcess' => [],
153 'processedTca' => [
154 'ctrl' => [],
155 'types' => [
156 'list' => [
157 'subtype_value_field' => 'list_type',
158 'subtypes_addlist' => [
159 'aType' => 'aField',
160 ]
161 ],
162 ],
163 ],
164 'databaseRow' => [
165 'list_type' => 'aType',
166 ],
167 ];
168
169 $expected = $input;
170 $expected['columnsToProcess'] = ['aField'];
171 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
172 }
173
174 /**
175 * @test
176 */
177 public function addDataRegistersMultipleSubtypesAddlistFields()
178 {
179 $input = [
180 'recordTypeValue' => 'aType',
181 'columnsToProcess' => [],
182 'processedTca' => [
183 'ctrl' => [],
184 'types' => [
185 'aType' => [
186 'subtype_value_field' => 'theSubtypeValueField',
187 'subtypes_addlist' => [
188 'theSubtypeValue' => 'aField, bField',
189 ]
190 ],
191 ],
192 ],
193 'databaseRow' => [
194 'theSubtypeValueField' => 'theSubtypeValue',
195 ],
196 ];
197
198 $expected = $input;
199 $expected['columnsToProcess'] = ['aField', 'bField'];
200 $this->assertSame($expected, (new TcaColumnsProcessCommon)->addData($input));
201 }
202 }