8add4866adf1d7dcd223b4ec8f7746fd72a4eddb
[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
19 /**
20 * Test case
21 */
22 class TcaColumnsProcessCommonTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
24 /**
25 * Subject is not notice free, disable E_NOTICES
26 */
27 protected static $suppressNotices = true;
28
29 /**
30 * @var TcaColumnsProcessCommon
31 */
32 protected $subject;
33
34 protected function setUp()
35 {
36 $this->subject = new TcaColumnsProcessCommon();
37 }
38
39 /**
40 * @test
41 */
42 public function addDataRegistersOrigUidColumn()
43 {
44 $input = [
45 'columnsToProcess' => [],
46 'processedTca' => [
47 'ctrl' => [
48 'origUid' => 't3_origuid'
49 ]
50 ]
51 ];
52
53 $expected = $input;
54 $expected['columnsToProcess'] = ['t3_origuid'];
55 $this->assertSame($expected, $this->subject->addData($input));
56 }
57
58 /**
59 * @test
60 */
61 public function addDataRegistersRecordTypeColumn()
62 {
63 $input = [
64 'columnsToProcess' => [],
65 'processedTca' => [
66 'ctrl' => [
67 'type' => 'doktype'
68 ]
69 ]
70 ];
71
72 $expected = $input;
73 $expected['columnsToProcess'] = ['doktype'];
74 $this->assertSame($expected, $this->subject->addData($input));
75 }
76
77 /**
78 * @test
79 */
80 public function addDataRegistersRecordTypeRelationColumn()
81 {
82 $input = [
83 'columnsToProcess' => [],
84 'processedTca' => [
85 'ctrl' => [
86 'type' => 'relation_field:foreign_type_field'
87 ]
88 ]
89 ];
90
91 $expected = $input;
92 $expected['columnsToProcess'] = ['relation_field'];
93 $this->assertSame($expected, $this->subject->addData($input));
94 }
95
96 /**
97 * @test
98 */
99 public function addDataRegistersLanguageFieldColumn()
100 {
101 $input = [
102 'columnsToProcess' => [],
103 'processedTca' => [
104 'ctrl' => [
105 'languageField' => 'sys_language_uid'
106 ]
107 ]
108 ];
109
110 $expected = $input;
111 $expected['columnsToProcess'] = ['sys_language_uid'];
112 $this->assertSame($expected, $this->subject->addData($input));
113 }
114
115 /**
116 * @test
117 */
118 public function addDataRegistersTransOrigPointerColumn()
119 {
120 $input = [
121 'columnsToProcess' => [],
122 'processedTca' => [
123 'ctrl' => [
124 'transOrigPointerField' => 'l10n_parent'
125 ]
126 ]
127 ];
128
129 $expected = $input;
130 $expected['columnsToProcess'] = ['l10n_parent'];
131 $this->assertSame($expected, $this->subject->addData($input));
132 }
133
134 /**
135 * @test
136 */
137 public function addDataRegistersTransOrigDiffSourceColumn()
138 {
139 $input = [
140 'columnsToProcess' => [],
141 'processedTca' => [
142 'ctrl' => [
143 'transOrigDiffSourceField' => 'l18n_diffsource'
144 ]
145 ]
146 ];
147
148 $expected = $input;
149 $expected['columnsToProcess'] = ['l18n_diffsource'];
150 $this->assertSame($expected, $this->subject->addData($input));
151 }
152
153 /**
154 * @test
155 */
156 public function addDataRegistersSingleSubtypesAddlistFields()
157 {
158 $input = [
159 'recordTypeValue' => 'list',
160 'columnsToProcess' => [],
161 'processedTca' => [
162 'types' => [
163 'list' => [
164 'subtype_value_field' => 'list_type',
165 'subtypes_addlist' => [
166 'aType' => 'aField',
167 ]
168 ],
169 ],
170 ],
171 'databaseRow' => [
172 'list_type' => 'aType',
173 ],
174 ];
175
176 $expected = $input;
177 $expected['columnsToProcess'] = ['aField'];
178 $this->assertSame($expected, $this->subject->addData($input));
179 }
180
181 /**
182 * @test
183 */
184 public function addDataRegistersMultipleSubtypesAddlistFields()
185 {
186 $input = [
187 'recordTypeValue' => 'aType',
188 'columnsToProcess' => [],
189 'processedTca' => [
190 'types' => [
191 'aType' => [
192 'subtype_value_field' => 'theSubtypeValueField',
193 'subtypes_addlist' => [
194 'theSubtypeValue' => 'aField, bField',
195 ]
196 ],
197 ],
198 ],
199 'databaseRow' => [
200 'theSubtypeValueField' => 'theSubtypeValue',
201 ],
202 ];
203
204 $expected = $input;
205 $expected['columnsToProcess'] = ['aField', 'bField'];
206 $this->assertSame($expected, $this->subject->addData($input));
207 }
208 }