‪TYPO3CMS  11.5
TcaTypesShowitemTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪TcaTypesShowitemTest extends UnitTestCase
27 {
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  $this->subject = new ‪TcaTypesShowitem();
34  }
35 
39  public function ‪addDataRemovesTypeRelatedFields(): void
40  {
41  $input = [
42  'databaseRow' => [],
43  'recordTypeValue' => 'aType',
44  'processedTca' => [
45  'types' => [
46  'aType' => [
47  'showitem' => 'foo',
48  'subtype_value_field' => 'bar',
49  'subtypes_excludelist' => [],
50  'subtypes_addlist' => [],
51  'bitmask_value_field' => 'foobar',
52  'bitmask_excludelist_bits' => [],
53  ],
54  ],
55  ],
56  ];
57  $expected = $input;
58  $expected['processedTca']['types']['aType'] = [
59  'showitem' => 'foo',
60  ];
61  self::assertSame($expected, $this->subject->addData($input));
62  }
63 
68  {
69  $input = [
70  'recordTypeValue' => 'aType',
71  'databaseRow' => [
72  'theSubtypeValueField' => 'theSubtypeValue',
73  ],
74  'processedTca' => [
75  'types' => [
76  'aType' => [
77  'showitem' => 'aField,theSubtypeValueField,anotherField',
78  'subtype_value_field' => 'theSubtypeValueField',
79  'subtypes_addlist' => [
80  'theSubtypeValue' => 'additionalField',
81  ],
82  ],
83  ],
84  ],
85  ];
86  $expected = [
87  'recordTypeValue' => 'aType',
88  'databaseRow' => [
89  'theSubtypeValueField' => 'theSubtypeValue',
90  ],
91  'processedTca' => [
92  'types' => [
93  'aType' => [
94  'showitem' => 'aField,theSubtypeValueField,additionalField,anotherField',
95  ],
96  ],
97  ],
98  ];
99  self::assertSame($expected, $this->subject->addData($input));
100  }
101 
106  {
107  $input = [
108  'recordTypeValue' => 'aType',
109  'databaseRow' => [
110  'theSubtypeValueField' => 'theSubtypeValue',
111  ],
112  'processedTca' => [
113  'types' => [
114  'aType' => [
115  'showitem' => 'aField,--palette--;;aPalette,anotherField',
116  'subtype_value_field' => 'theSubtypeValueField',
117  'subtypes_addlist' => [
118  'theSubtypeValue' => 'additionalField',
119  ],
120  ],
121  ],
122  'palettes' => [
123  'aPalette' => [
124  'showitem' => 'foo,theSubtypeValueField,bar',
125  ],
126  ],
127  ],
128  ];
129  $expected = [
130  'recordTypeValue' => 'aType',
131  'databaseRow' => [
132  'theSubtypeValueField' => 'theSubtypeValue',
133  ],
134  'processedTca' => [
135  'types' => [
136  'aType' => [
137  'showitem' => 'aField,--palette--;;aPalette,additionalField,anotherField',
138  ],
139  ],
140  'palettes' => [
141  'aPalette' => [
142  'showitem' => 'foo,theSubtypeValueField,bar',
143  ],
144  ],
145  ],
146  ];
147  self::assertSame($expected, $this->subject->addData($input));
148  }
149 
154  {
155  $input = [
156  'recordTypeValue' => 'aType',
157  'databaseRow' => [
158  'theSubtypeValueField' => 'subtypeMatch',
159  ],
160  'processedTca' => [
161  'types' => [
162  'aType' => [
163  'showitem' => 'aField, removeMe, anotherField',
164  'subtype_value_field' => 'theSubtypeValueField',
165  'subtypes_excludelist' => [
166  'subtypeMatch' => 'removeMe',
167  ],
168  ],
169  ],
170  ],
171  ];
172  $expected = [
173  'recordTypeValue' => 'aType',
174  'databaseRow' => [
175  'theSubtypeValueField' => 'subtypeMatch',
176  ],
177  'processedTca' => [
178  'types' => [
179  'aType' => [
180  'showitem' => 'aField,anotherField',
181  ],
182  ],
183  ],
184  ];
185  self::assertSame($expected, $this->subject->addData($input));
186  }
187 
192  {
193  $input = [
194  'recordTypeValue' => 'aType',
195  'databaseRow' => [
196  'theSubtypeValueField' => 'subtypeMatch',
197  ],
198  'processedTca' => [
199  'types' => [
200  'aType' => [
201  'showitem' => '',
202  'subtype_value_field' => 'theSubtypeValueField',
203  'subtypes_excludelist' => [
204  'subtypeMatch' => 'removeMe',
205  ],
206  ],
207  ],
208  'palettes' => [
209  'aPalette' => [
210  'showitem' => 'aField, removeMe, anotherField',
211  ],
212  ],
213  ],
214  ];
215  $expected = [
216  'recordTypeValue' => 'aType',
217  'databaseRow' => [
218  'theSubtypeValueField' => 'subtypeMatch',
219  ],
220  'processedTca' => [
221  'types' => [
222  'aType' => [
223  'showitem' => '',
224  ],
225  ],
226  'palettes' => [
227  'aPalette' => [
228  'showitem' => 'aField,anotherField',
229  ],
230  ],
231  ],
232  ];
233  self::assertSame($expected, $this->subject->addData($input));
234  }
235 
240  {
241  $input = [
242  'recordTypeValue' => 'aType',
243  'databaseRow' => [
244  'theSubtypeValueField' => 10, // 1 0 1 0
245  ],
246  'processedTca' => [
247  'types' => [
248  'aType' => [
249  'showitem' => 'aField, removedBy3, anotherField, removedBy2',
250  'bitmask_value_field' => 'theSubtypeValueField',
251  'bitmask_excludelist_bits' => [
252  '-2' => 'removedBy2', // Remove if bit 2 is NOT set
253  '+3' => 'removedBy3', // Remove if bit 3 is set
254  ],
255  ],
256  ],
257  ],
258  ];
259  $expected = [
260  'recordTypeValue' => 'aType',
261  'databaseRow' => [
262  'theSubtypeValueField' => 10,
263  ],
264  'processedTca' => [
265  'types' => [
266  'aType' => [
267  'showitem' => 'aField,anotherField',
268  ],
269  ],
270  ],
271  ];
272  self::assertSame($expected, $this->subject->addData($input));
273  }
274 
279  {
280  $input = [
281  'recordTypeValue' => 'aType',
282  'databaseRow' => [
283  'theSubtypeValueField' => 10, // 1 0 1 0
284  ],
285  'processedTca' => [
286  'types' => [
287  'aType' => [
288  'showitem' => '',
289  'bitmask_value_field' => 'theSubtypeValueField',
290  'bitmask_excludelist_bits' => [
291  '-2' => 'removeMe', // Remove if bit 2 is NOT set
292  '+3' => 'removeMe2', // Remove if bit 3 is set
293  ],
294  ],
295  ],
296  'palettes' => [
297  'aPalette' => [
298  'showitem' => 'aField, removeMe, anotherField',
299  ],
300  'anotherPalette' => [
301  'showitem' => 'removeMe2',
302  ],
303  ],
304  ],
305  ];
306  $expected = [
307  'recordTypeValue' => 'aType',
308  'databaseRow' => [
309  'theSubtypeValueField' => 10,
310  ],
311  'processedTca' => [
312  'types' => [
313  'aType' => [
314  'showitem' => '',
315  ],
316  ],
317  'palettes' => [
318  'aPalette' => [
319  'showitem' => 'aField,anotherField',
320  ],
321  'anotherPalette' => [
322  'showitem' => '',
323  ],
324  ],
325  ],
326  ];
327  self::assertSame($expected, $this->subject->addData($input));
328  }
329 }
‪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:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18