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