‪TYPO3CMS  ‪main
TcaColumnsProcessShowitemTest.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 ‪TcaColumnsProcessShowitemTest extends UnitTestCase
25 {
26  #[Test]
28  {
29  $input = [
30  'recordTypeValue' => 'aType',
31  'tableName' => 'aTable',
32  'processedTca' => [
33  'columns' => [
34  'aField' => [
35  'type' => 'aType',
36  ],
37  ],
38  'types' => [
39  'aType' => [],
40  ],
41  ],
42  ];
43  $this->expectException(\UnexpectedValueException::class);
44  $this->expectExceptionCode(1438614542);
45  (new ‪TcaColumnsProcessShowitem())->addData($input);
46  }
47 
48  #[Test]
50  {
51  $input = [
52  'columnsToProcess' => [],
53  'databaseRow' => [],
54  'recordTypeValue' => 'aType',
55  'isInlineChild' => false,
56  'processedTca' => [
57  'types' => [
58  'aType' => [
59  'showitem' => 'keepMe',
60  ],
61  ],
62  'columns' => [
63  'keepMe' => [
64  'config' => [
65  'type' => 'input',
66  ],
67  ],
68  'aField' => [
69  'config' => [
70  'type' => 'input',
71  ],
72  ],
73  ],
74  ],
75  ];
76 
77  $expected = $input;
78  $expected['columnsToProcess'] = ['keepMe'];
79 
80  self::assertSame($expected, (new ‪TcaColumnsProcessShowitem())->addData($input));
81  }
82 
83  #[Test]
85  {
86  $input = [
87  'columnsToProcess' => [],
88  'databaseRow' => [],
89  'recordTypeValue' => 'aType',
90  'isInlineChild' => false,
91  'processedTca' => [
92  'types' => [
93  'aType' => [
94  'showitem' => '--palette--;;aPalette',
95  ],
96  ],
97  'palettes' => [
98  'aPalette' => [
99  'showitem' => 'keepMe',
100  ],
101  ],
102  'columns' => [
103  'keepMe' => [
104  'config' => [
105  'type' => 'input',
106  ],
107  ],
108  'bField' => [
109  'config' => [
110  'type' => 'input',
111  ],
112  ],
113  ],
114  ],
115  ];
116 
117  $expected = $input;
118  $expected['columnsToProcess'] = ['keepMe'];
119 
120  self::assertSame($expected, (new ‪TcaColumnsProcessShowitem())->addData($input));
121  }
122 
123  #[Test]
125  {
126  $input = [
127  'databaseRow' => [],
128  'recordTypeValue' => 'aType',
129  'isInlineChild' => false,
130  'processedTca' => [
131  'types' => [
132  'aType' => [
133  'showitem' => '--palette--;;aPalette, anotherField',
134  ],
135  ],
136  'palettes' => [
137  'aPalette' => [
138  'showitem' => 'aField',
139  ],
140  ],
141  'columns' => [
142  'aField' => [
143  'config' => [
144  'type' => 'input',
145  ],
146  ],
147  'removeMe' => [
148  'config' => [
149  'type' => 'input',
150  ],
151  ],
152  'anotherField' => [
153  'config' => [
154  'type' => 'input',
155  ],
156  ],
157  ],
158  ],
159  ];
160 
161  $expected = $input;
162  $expected['columnsToProcess'] = ['aField', 'anotherField'];
163 
164  self::assertSame($expected, (new ‪TcaColumnsProcessShowitem())->addData($input));
165  }
166 
167  #[Test]
169  {
170  $input = [
171  'command' => 'edit',
172  'databaseRow' => [
173  'uid' => 42,
174  ],
175  'recordTypeValue' => 'aType',
176  'processedTca' => [
177  'types' => [
178  'aType' => [
179  'showitem' => 'aField',
180  ],
181  ],
182  'columns' => [
183  'aField' => [
184  'config' => [
185  'type' => 'input',
186  ],
187  ],
188  ],
189  ],
190  'inlineParentConfig' => [
191  'foreign_table' => 'aTable',
192  ],
193  'isInlineChild' => true,
194  'isInlineChildExpanded' => false,
195  'isInlineAjaxOpeningContext' => false,
196  'inlineExpandCollapseStateArray' => [],
197  ];
198  $expected = $input;
199  self::assertSame($expected, (new ‪TcaColumnsProcessShowitem())->addData($input));
200  }
201 
202  #[Test]
204  {
205  $input = [
206  'command' => 'edit',
207  'databaseRow' => [
208  'uid' => 42,
209  ],
210  'recordTypeValue' => 'aType',
211  'processedTca' => [
212  'types' => [
213  'aType' => [
214  'showitem' => 'aField',
215  ],
216  ],
217  'columns' => [
218  'aField' => [
219  'config' => [
220  'type' => 'input',
221  ],
222  ],
223  ],
224  ],
225  'inlineParentConfig' => [
226  'foreign_table' => 'aTable',
227  'appearance' => [
228  'collapseAll' => true,
229  ],
230  ],
231  'isInlineChild' => true,
232  'isInlineChildExpanded' => false,
233  'isInlineAjaxOpeningContext' => false,
234  'inlineExpandCollapseStateArray' => [
235  'aTable' => [
236  42,
237  ],
238  ],
239  ];
240  $expected = $input;
241  self::assertSame($expected, (new ‪TcaColumnsProcessShowitem())->addData($input));
242  }
243 
244  #[Test]
246  {
247  $input = [
248  'command' => 'edit',
249  'databaseRow' => [
250  'uid' => 42,
251  ],
252  'recordTypeValue' => 'aType',
253  'processedTca' => [
254  'types' => [
255  'aType' => [
256  'showitem' => 'aField',
257  ],
258  ],
259  'columns' => [
260  'aField' => [
261  'config' => [
262  'type' => 'input',
263  ],
264  ],
265  ],
266  ],
267  'inlineParentConfig' => [
268  'foreign_table' => 'aTable',
269  ],
270  'isInlineChild' => true,
271  'isInlineChildExpanded' => true,
272  'isInlineAjaxOpeningContext' => false,
273  'inlineExpandCollapseStateArray' => [
274  'aTable' => [
275  42,
276  ],
277  ],
278  ];
279  $expected = $input;
280  $expected['columnsToProcess'] = ['aField'];
281  self::assertSame($expected, (new ‪TcaColumnsProcessShowitem())->addData($input));
282  }
283 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataSkipsColumnsForCollapsedInlineChild
‪addDataSkipsColumnsForCollapsedInlineChild()
Definition: TcaColumnsProcessShowitemTest.php:168
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataRegistersColumnsFieldReferencedInShowitems
‪addDataRegistersColumnsFieldReferencedInShowitems()
Definition: TcaColumnsProcessShowitemTest.php:49
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataSkipsColumnsNotReferencedInShowitemOrPalette
‪addDataSkipsColumnsNotReferencedInShowitemOrPalette()
Definition: TcaColumnsProcessShowitemTest.php:124
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataAddsColumnsForExpandedInlineChild
‪addDataAddsColumnsForExpandedInlineChild()
Definition: TcaColumnsProcessShowitemTest.php:245
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessShowitem
Definition: TcaColumnsProcessShowitem.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataThrowsExceptionIfTypesHasNoShowitem
‪addDataThrowsExceptionIfTypesHasNoShowitem()
Definition: TcaColumnsProcessShowitemTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest
Definition: TcaColumnsProcessShowitemTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataSkipsColumnsForCollapsedAllInlineChild
‪addDataSkipsColumnsForCollapsedAllInlineChild()
Definition: TcaColumnsProcessShowitemTest.php:203
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessShowitemTest\addDataKeepsColumnsFieldReferencedInPalette
‪addDataKeepsColumnsFieldReferencedInPalette()
Definition: TcaColumnsProcessShowitemTest.php:84
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18