2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaTypesShowitem
;
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase
;
23 class TcaTypesShowitemTest
extends UnitTestCase
26 * @var TcaTypesShowitem
30 protected function setUp(): void
33 $this->subject
= new TcaTypesShowitem();
39 public function addDataRemovesTypeRelatedFields()
43 'recordTypeValue' => 'aType',
48 'subtype_value_field' => 'bar',
49 'subtypes_excludelist' => [],
50 'subtypes_addlist' => [],
51 'bitmask_value_field' => 'foobar',
52 'bitmask_excludelist_bits' => [],
58 $expected['processedTca']['types']['aType'] = [
61 $this->assertSame($expected, $this->subject
->addData($input));
67 public function addDataInsertsMatchingSubtypeAddListAfterSubtypeValueField()
70 'recordTypeValue' => 'aType',
72 'theSubtypeValueField' => 'theSubtypeValue',
77 'showitem' => 'aField,theSubtypeValueField,anotherField',
78 'subtype_value_field' => 'theSubtypeValueField',
79 'subtypes_addlist' => [
80 'theSubtypeValue' => 'additionalField',
87 'recordTypeValue' => 'aType',
89 'theSubtypeValueField' => 'theSubtypeValue',
94 'showitem' => 'aField,theSubtypeValueField,additionalField,anotherField',
99 $this->assertSame($expected, $this->subject
->addData($input));
105 public function addDataInsertsMatchingSubtypeAddListAfterPaletteWithSubtypeValueField()
108 'recordTypeValue' => 'aType',
110 'theSubtypeValueField' => 'theSubtypeValue',
115 'showitem' => 'aField,--palette--;;aPalette,anotherField',
116 'subtype_value_field' => 'theSubtypeValueField',
117 'subtypes_addlist' => [
118 'theSubtypeValue' => 'additionalField',
124 'showitem' => 'foo,theSubtypeValueField,bar',
130 'recordTypeValue' => 'aType',
132 'theSubtypeValueField' => 'theSubtypeValue',
137 'showitem' => 'aField,--palette--;;aPalette,additionalField,anotherField',
142 'showitem' => 'foo,theSubtypeValueField,bar',
147 $this->assertSame($expected, $this->subject
->addData($input));
153 public function addDataRemovesMatchingSubtypeExcludeListItems()
156 'recordTypeValue' => 'aType',
158 'theSubtypeValueField' => 'subtypeMatch',
163 'showitem' => 'aField, removeMe, anotherField',
164 'subtype_value_field' => 'theSubtypeValueField',
165 'subtypes_excludelist' => [
166 'subtypeMatch' => 'removeMe',
173 'recordTypeValue' => 'aType',
175 'theSubtypeValueField' => 'subtypeMatch',
180 'showitem' => 'aField,anotherField',
185 $this->assertSame($expected, $this->subject
->addData($input));
191 public function addDataRemovesMatchingSubtypeExcludeListItemsFromPalettes()
194 'recordTypeValue' => 'aType',
196 'theSubtypeValueField' => 'subtypeMatch',
202 'subtype_value_field' => 'theSubtypeValueField',
203 'subtypes_excludelist' => [
204 'subtypeMatch' => 'removeMe',
210 'showitem' => 'aField, removeMe, anotherField',
216 'recordTypeValue' => 'aType',
218 'theSubtypeValueField' => 'subtypeMatch',
228 'showitem' => 'aField,anotherField',
233 $this->assertSame($expected, $this->subject
->addData($input));
239 public function addDataRemovesMatchingBitmaskExcludeListItems()
242 'recordTypeValue' => 'aType',
244 'theSubtypeValueField' => 10, // 1 0 1 0
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
260 'recordTypeValue' => 'aType',
262 'theSubtypeValueField' => 10,
267 'showitem' => 'aField,anotherField',
272 $this->assertSame($expected, $this->subject
->addData($input));
278 public function addDataRemovesMatchingBitmaskExcludeListItemsFromPalettes()
281 'recordTypeValue' => 'aType',
283 'theSubtypeValueField' => 10, // 1 0 1 0
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
298 'showitem' => 'aField, removeMe, anotherField',
300 'anotherPalette' => [
301 'showitem' => 'removeMe2',
307 'recordTypeValue' => 'aType',
309 'theSubtypeValueField' => 10,
319 'showitem' => 'aField,anotherField',
321 'anotherPalette' => [
327 $this->assertSame($expected, $this->subject
->addData($input));