‪TYPO3CMS  10.4
TcaTypesShowitemTest.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 ‪TcaTypesShowitemTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->subject = new ‪TcaTypesShowitem();
35  }
36 
40  public function ‪addDataRemovesTypeRelatedFields()
41  {
42  $input = [
43  'databaseRow' => [],
44  'recordTypeValue' => 'aType',
45  'processedTca' => [
46  'types' => [
47  'aType' => [
48  'showitem' => 'foo',
49  'subtype_value_field' => 'bar',
50  'subtypes_excludelist' => [],
51  'subtypes_addlist' => [],
52  'bitmask_value_field' => 'foobar',
53  'bitmask_excludelist_bits' => [],
54  ],
55  ],
56  ],
57  ];
58  $expected = $input;
59  $expected['processedTca']['types']['aType'] = [
60  'showitem' => 'foo',
61  ];
62  self::assertSame($expected, $this->subject->addData($input));
63  }
64 
69  {
70  $input = [
71  'recordTypeValue' => 'aType',
72  'databaseRow' => [
73  'theSubtypeValueField' => 'theSubtypeValue',
74  ],
75  'processedTca' => [
76  'types' => [
77  'aType' => [
78  'showitem' => 'aField,theSubtypeValueField,anotherField',
79  'subtype_value_field' => 'theSubtypeValueField',
80  'subtypes_addlist' => [
81  'theSubtypeValue' => 'additionalField',
82  ],
83  ],
84  ],
85  ],
86  ];
87  $expected = [
88  'recordTypeValue' => 'aType',
89  'databaseRow' => [
90  'theSubtypeValueField' => 'theSubtypeValue',
91  ],
92  'processedTca' => [
93  'types' => [
94  'aType' => [
95  'showitem' => 'aField,theSubtypeValueField,additionalField,anotherField',
96  ],
97  ],
98  ],
99  ];
100  self::assertSame($expected, $this->subject->addData($input));
101  }
102 
107  {
108  $input = [
109  'recordTypeValue' => 'aType',
110  'databaseRow' => [
111  'theSubtypeValueField' => 'theSubtypeValue',
112  ],
113  'processedTca' => [
114  'types' => [
115  'aType' => [
116  'showitem' => 'aField,--palette--;;aPalette,anotherField',
117  'subtype_value_field' => 'theSubtypeValueField',
118  'subtypes_addlist' => [
119  'theSubtypeValue' => 'additionalField',
120  ],
121  ],
122  ],
123  'palettes' => [
124  'aPalette' => [
125  'showitem' => 'foo,theSubtypeValueField,bar',
126  ],
127  ],
128  ],
129  ];
130  $expected = [
131  'recordTypeValue' => 'aType',
132  'databaseRow' => [
133  'theSubtypeValueField' => 'theSubtypeValue',
134  ],
135  'processedTca' => [
136  'types' => [
137  'aType' => [
138  'showitem' => 'aField,--palette--;;aPalette,additionalField,anotherField',
139  ],
140  ],
141  'palettes' => [
142  'aPalette' => [
143  'showitem' => 'foo,theSubtypeValueField,bar',
144  ],
145  ],
146  ],
147  ];
148  self::assertSame($expected, $this->subject->addData($input));
149  }
150 
155  {
156  $input = [
157  'recordTypeValue' => 'aType',
158  'databaseRow' => [
159  'theSubtypeValueField' => 'subtypeMatch',
160  ],
161  'processedTca' => [
162  'types' => [
163  'aType' => [
164  'showitem' => 'aField, removeMe, anotherField',
165  'subtype_value_field' => 'theSubtypeValueField',
166  'subtypes_excludelist' => [
167  'subtypeMatch' => 'removeMe',
168  ],
169  ],
170  ],
171  ],
172  ];
173  $expected = [
174  'recordTypeValue' => 'aType',
175  'databaseRow' => [
176  'theSubtypeValueField' => 'subtypeMatch',
177  ],
178  'processedTca' => [
179  'types' => [
180  'aType' => [
181  'showitem' => 'aField,anotherField',
182  ],
183  ],
184  ],
185  ];
186  self::assertSame($expected, $this->subject->addData($input));
187  }
188 
193  {
194  $input = [
195  'recordTypeValue' => 'aType',
196  'databaseRow' => [
197  'theSubtypeValueField' => 'subtypeMatch',
198  ],
199  'processedTca' => [
200  'types' => [
201  'aType' => [
202  'showitem' => '',
203  'subtype_value_field' => 'theSubtypeValueField',
204  'subtypes_excludelist' => [
205  'subtypeMatch' => 'removeMe',
206  ],
207  ],
208  ],
209  'palettes' => [
210  'aPalette' => [
211  'showitem' => 'aField, removeMe, anotherField',
212  ],
213  ],
214  ],
215  ];
216  $expected = [
217  'recordTypeValue' => 'aType',
218  'databaseRow' => [
219  'theSubtypeValueField' => 'subtypeMatch',
220  ],
221  'processedTca' => [
222  'types' => [
223  'aType' => [
224  'showitem' => '',
225  ],
226  ],
227  'palettes' => [
228  'aPalette' => [
229  'showitem' => 'aField,anotherField',
230  ],
231  ],
232  ],
233  ];
234  self::assertSame($expected, $this->subject->addData($input));
235  }
236 
241  {
242  $input = [
243  'recordTypeValue' => 'aType',
244  'databaseRow' => [
245  'theSubtypeValueField' => 10, // 1 0 1 0
246  ],
247  'processedTca' => [
248  'types' => [
249  'aType' => [
250  'showitem' => 'aField, removedBy3, anotherField, removedBy2',
251  'bitmask_value_field' => 'theSubtypeValueField',
252  'bitmask_excludelist_bits' => [
253  '-2' => 'removedBy2', // Remove if bit 2 is NOT set
254  '+3' => 'removedBy3', // Remove if bit 3 is set
255  ],
256  ],
257  ],
258  ],
259  ];
260  $expected = [
261  'recordTypeValue' => 'aType',
262  'databaseRow' => [
263  'theSubtypeValueField' => 10,
264  ],
265  'processedTca' => [
266  'types' => [
267  'aType' => [
268  'showitem' => 'aField,anotherField',
269  ],
270  ],
271  ],
272  ];
273  self::assertSame($expected, $this->subject->addData($input));
274  }
275 
280  {
281  $input = [
282  'recordTypeValue' => 'aType',
283  'databaseRow' => [
284  'theSubtypeValueField' => 10, // 1 0 1 0
285  ],
286  'processedTca' => [
287  'types' => [
288  'aType' => [
289  'showitem' => '',
290  'bitmask_value_field' => 'theSubtypeValueField',
291  'bitmask_excludelist_bits' => [
292  '-2' => 'removeMe', // Remove if bit 2 is NOT set
293  '+3' => 'removeMe2', // Remove if bit 3 is set
294  ],
295  ],
296  ],
297  'palettes' => [
298  'aPalette' => [
299  'showitem' => 'aField, removeMe, anotherField',
300  ],
301  'anotherPalette' => [
302  'showitem' => 'removeMe2',
303  ],
304  ],
305  ],
306  ];
307  $expected = [
308  'recordTypeValue' => 'aType',
309  'databaseRow' => [
310  'theSubtypeValueField' => 10,
311  ],
312  'processedTca' => [
313  'types' => [
314  'aType' => [
315  'showitem' => '',
316  ],
317  ],
318  'palettes' => [
319  'aPalette' => [
320  'showitem' => 'aField,anotherField',
321  ],
322  'anotherPalette' => [
323  'showitem' => '',
324  ],
325  ],
326  ],
327  ];
328  self::assertSame($expected, $this->subject->addData($input));
329  }
330 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataInsertsMatchingSubtypeAddListAfterPaletteWithSubtypeValueField
‪addDataInsertsMatchingSubtypeAddListAfterPaletteWithSubtypeValueField()
Definition: TcaTypesShowitemTest.php:105
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesMatchingSubtypeExcludeListItems
‪addDataRemovesMatchingSubtypeExcludeListItems()
Definition: TcaTypesShowitemTest.php:153
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaTypesShowitem
Definition: TcaTypesShowitem.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\setUp
‪setUp()
Definition: TcaTypesShowitemTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesTypeRelatedFields
‪addDataRemovesTypeRelatedFields()
Definition: TcaTypesShowitemTest.php:39
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\$subject
‪TcaTypesShowitem $subject
Definition: TcaTypesShowitemTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesMatchingBitmaskExcludeListItems
‪addDataRemovesMatchingBitmaskExcludeListItems()
Definition: TcaTypesShowitemTest.php:239
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesMatchingSubtypeExcludeListItemsFromPalettes
‪addDataRemovesMatchingSubtypeExcludeListItemsFromPalettes()
Definition: TcaTypesShowitemTest.php:191
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataInsertsMatchingSubtypeAddListAfterSubtypeValueField
‪addDataInsertsMatchingSubtypeAddListAfterSubtypeValueField()
Definition: TcaTypesShowitemTest.php:67
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesMatchingBitmaskExcludeListItemsFromPalettes
‪addDataRemovesMatchingBitmaskExcludeListItemsFromPalettes()
Definition: TcaTypesShowitemTest.php:278
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest
Definition: TcaTypesShowitemTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18