‪TYPO3CMS  ‪main
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 
20 use PHPUnit\Framework\Attributes\Test;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 final class ‪TcaTypesShowitemTest extends UnitTestCase
25 {
27 
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  $this->subject = new ‪TcaTypesShowitem();
32  }
33 
34  #[Test]
35  public function ‪addDataRemovesTypeRelatedFields(): void
36  {
37  $input = [
38  'databaseRow' => [],
39  'recordTypeValue' => 'aType',
40  'processedTca' => [
41  'types' => [
42  'aType' => [
43  'showitem' => 'foo',
44  'subtype_value_field' => 'bar',
45  'subtypes_excludelist' => [],
46  'subtypes_addlist' => [],
47  ],
48  ],
49  ],
50  ];
51  $expected = $input;
52  $expected['processedTca']['types']['aType'] = [
53  'showitem' => 'foo',
54  ];
55  self::assertSame($expected, $this->subject->addData($input));
56  }
57 
58  #[Test]
60  {
61  $input = [
62  'recordTypeValue' => 'aType',
63  'databaseRow' => [
64  'theSubtypeValueField' => 'theSubtypeValue',
65  ],
66  'processedTca' => [
67  'types' => [
68  'aType' => [
69  'showitem' => 'aField,theSubtypeValueField,anotherField',
70  'subtype_value_field' => 'theSubtypeValueField',
71  'subtypes_addlist' => [
72  'theSubtypeValue' => 'additionalField',
73  ],
74  ],
75  ],
76  ],
77  ];
78  $expected = [
79  'recordTypeValue' => 'aType',
80  'databaseRow' => [
81  'theSubtypeValueField' => 'theSubtypeValue',
82  ],
83  'processedTca' => [
84  'types' => [
85  'aType' => [
86  'showitem' => 'aField,theSubtypeValueField,additionalField,anotherField',
87  ],
88  ],
89  ],
90  ];
91  self::assertSame($expected, $this->subject->addData($input));
92  }
93 
94  #[Test]
96  {
97  $input = [
98  'recordTypeValue' => 'aType',
99  'databaseRow' => [
100  'theSubtypeValueField' => 'theSubtypeValue',
101  ],
102  'processedTca' => [
103  'types' => [
104  'aType' => [
105  'showitem' => 'aField,--palette--;;aPalette,anotherField',
106  'subtype_value_field' => 'theSubtypeValueField',
107  'subtypes_addlist' => [
108  'theSubtypeValue' => 'additionalField',
109  ],
110  ],
111  ],
112  'palettes' => [
113  'aPalette' => [
114  'showitem' => 'foo,theSubtypeValueField,bar',
115  ],
116  ],
117  ],
118  ];
119  $expected = [
120  'recordTypeValue' => 'aType',
121  'databaseRow' => [
122  'theSubtypeValueField' => 'theSubtypeValue',
123  ],
124  'processedTca' => [
125  'types' => [
126  'aType' => [
127  'showitem' => 'aField,--palette--;;aPalette,additionalField,anotherField',
128  ],
129  ],
130  'palettes' => [
131  'aPalette' => [
132  'showitem' => 'foo,theSubtypeValueField,bar',
133  ],
134  ],
135  ],
136  ];
137  self::assertSame($expected, $this->subject->addData($input));
138  }
139 
140  #[Test]
142  {
143  $input = [
144  'recordTypeValue' => 'aType',
145  'databaseRow' => [
146  'theSubtypeValueField' => 'subtypeMatch',
147  ],
148  'processedTca' => [
149  'types' => [
150  'aType' => [
151  'showitem' => 'aField, removeMe, anotherField',
152  'subtype_value_field' => 'theSubtypeValueField',
153  'subtypes_excludelist' => [
154  'subtypeMatch' => 'removeMe',
155  ],
156  ],
157  ],
158  ],
159  ];
160  $expected = [
161  'recordTypeValue' => 'aType',
162  'databaseRow' => [
163  'theSubtypeValueField' => 'subtypeMatch',
164  ],
165  'processedTca' => [
166  'types' => [
167  'aType' => [
168  'showitem' => 'aField,anotherField',
169  ],
170  ],
171  ],
172  ];
173  self::assertSame($expected, $this->subject->addData($input));
174  }
175 
176  #[Test]
178  {
179  $input = [
180  'recordTypeValue' => 'aType',
181  'databaseRow' => [
182  'theSubtypeValueField' => 'subtypeMatch',
183  ],
184  'processedTca' => [
185  'types' => [
186  'aType' => [
187  'showitem' => '',
188  'subtype_value_field' => 'theSubtypeValueField',
189  'subtypes_excludelist' => [
190  'subtypeMatch' => 'removeMe',
191  ],
192  ],
193  ],
194  'palettes' => [
195  'aPalette' => [
196  'showitem' => 'aField, removeMe, anotherField',
197  ],
198  ],
199  ],
200  ];
201  $expected = [
202  'recordTypeValue' => 'aType',
203  'databaseRow' => [
204  'theSubtypeValueField' => 'subtypeMatch',
205  ],
206  'processedTca' => [
207  'types' => [
208  'aType' => [
209  'showitem' => '',
210  ],
211  ],
212  'palettes' => [
213  'aPalette' => [
214  'showitem' => 'aField,anotherField',
215  ],
216  ],
217  ],
218  ];
219  self::assertSame($expected, $this->subject->addData($input));
220  }
221 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataInsertsMatchingSubtypeAddListAfterPaletteWithSubtypeValueField
‪addDataInsertsMatchingSubtypeAddListAfterPaletteWithSubtypeValueField()
Definition: TcaTypesShowitemTest.php:95
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesMatchingSubtypeExcludeListItems
‪addDataRemovesMatchingSubtypeExcludeListItems()
Definition: TcaTypesShowitemTest.php:141
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaTypesShowitem
Definition: TcaTypesShowitem.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\setUp
‪setUp()
Definition: TcaTypesShowitemTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesTypeRelatedFields
‪addDataRemovesTypeRelatedFields()
Definition: TcaTypesShowitemTest.php:35
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\$subject
‪TcaTypesShowitem $subject
Definition: TcaTypesShowitemTest.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataRemovesMatchingSubtypeExcludeListItemsFromPalettes
‪addDataRemovesMatchingSubtypeExcludeListItemsFromPalettes()
Definition: TcaTypesShowitemTest.php:177
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest\addDataInsertsMatchingSubtypeAddListAfterSubtypeValueField
‪addDataInsertsMatchingSubtypeAddListAfterSubtypeValueField()
Definition: TcaTypesShowitemTest.php:59
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTypesShowitemTest
Definition: TcaTypesShowitemTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18