TYPO3  7.6
TcaColumnsProcessShowitemTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
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.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3\CMS\Core\Tests\UnitTestCase;
19 
23 class TcaColumnsProcessShowitemTest extends UnitTestCase
24 {
28  protected $subject;
29 
30  protected function setUp()
31  {
32  $this->subject = new TcaColumnsProcessShowitem();
33  }
34 
39  {
40  $input = [
41  'recordTypeValue' => 'aType',
42  'processedTca' => [
43  'columns' => [
44  'aField' => [
45  'type' => 'aType',
46  ],
47  ],
48  'types' => [
49  'aType' => [],
50  ],
51  ],
52  ];
53  $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1438614542);
54  $this->subject->addData($input);
55  }
56 
61  {
62  $input = [
63  'columnsToProcess' => [],
64  'databaseRow' => [],
65  'recordTypeValue' => 'aType',
66  'processedTca' => [
67  'types' => [
68  'aType' => [
69  'showitem' => 'keepMe'
70  ],
71  ],
72  'columns' => [
73  'keepMe' => [
74  'config' => [
75  'type' => 'input',
76  ]
77  ],
78  'aField' => [
79  'config' => [
80  'type' => 'input',
81  ]
82  ]
83  ]
84  ]
85  ];
86 
87  $expected = $input;
88  $expected['columnsToProcess'] = ['keepMe'];
89 
90  $this->assertSame($expected, $this->subject->addData($input));
91  }
92 
97  {
98  $input = [
99  'columnsToProcess' => [],
100  'databaseRow' => [],
101  'recordTypeValue' => 'aType',
102  'processedTca' => [
103  'types' => [
104  'aType' => [
105  'showitem' => '--palette--;;aPalette'
106  ],
107  ],
108  'palettes' => [
109  'aPalette' => [
110  'showitem' => 'keepMe',
111  ],
112  ],
113  'columns' => [
114  'keepMe' => [
115  'config' => [
116  'type' => 'input',
117  ]
118  ],
119  'bField' => [
120  'config' => [
121  'type' => 'input',
122  ]
123  ]
124  ]
125  ]
126  ];
127 
128  $expected = $input;
129  $expected['columnsToProcess'] = ['keepMe'];
130 
131  $this->assertSame($expected, $this->subject->addData($input));
132  }
133 
138  {
139  $input = [
140  'databaseRow' => [],
141  'recordTypeValue' => 'aType',
142  'processedTca' => [
143  'types' => [
144  'aType' => [
145  'showitem' => '--palette--;;aPalette, anotherField'
146  ],
147  ],
148  'palettes' => [
149  'aPalette' => [
150  'showitem' => 'aField',
151  ],
152  ],
153  'columns' => [
154  'aField' => [
155  'config' => [
156  'type' => 'input',
157  ]
158  ],
159  'removeMe' => [
160  'config' => [
161  'type' => 'input',
162  ]
163  ],
164  'anotherField' => [
165  'config' => [
166  'type' => 'input',
167  ]
168  ]
169  ]
170  ]
171  ];
172 
173  $expected = $input;
174  $expected['columnsToProcess'] = ['aField', 'anotherField'];
175 
176  $this->assertSame($expected, $this->subject->addData($input));
177  }
178 
183  {
184  $input = [
185  'command' => 'edit',
186  'databaseRow' => [
187  'uid' => 42,
188  ],
189  'recordTypeValue' => 'aType',
190  'processedTca' => [
191  'types' => [
192  'aType' => [
193  'showitem' => 'aField',
194  ],
195  ],
196  'columns' => [
197  'aField' => [
198  'config' => [
199  'type' => 'input',
200  ]
201  ],
202  ],
203  ],
204  'inlineParentConfig' => [
205  'foreign_table' => 'aTable',
206  ],
207  'isInlineChild' => true,
208  'isInlineAjaxOpeningContext' => false,
209  'inlineExpandCollapseStateArray' => [],
210  ];
211  $expected = $input;
212  $this->assertSame($expected, $this->subject->addData($input));
213  }
214 
219  {
220  $input = [
221  'command' => 'edit',
222  'databaseRow' => [
223  'uid' => 42,
224  ],
225  'recordTypeValue' => 'aType',
226  'processedTca' => [
227  'types' => [
228  'aType' => [
229  'showitem' => 'aField',
230  ],
231  ],
232  'columns' => [
233  'aField' => [
234  'config' => [
235  'type' => 'input',
236  ]
237  ],
238  ],
239  ],
240  'inlineParentConfig' => [
241  'foreign_table' => 'aTable',
242  'appearance' => [
243  'collapseAll' => true,
244  ],
245  ],
246  'isInlineChild' => true,
247  'isInlineAjaxOpeningContext' => false,
248  'inlineExpandCollapseStateArray' => [
249  'aTable' => [
250  42,
251  ],
252  ],
253  ];
254  $expected = $input;
255  $this->assertSame($expected, $this->subject->addData($input));
256  }
257 
262  {
263  $input = [
264  'command' => 'edit',
265  'databaseRow' => [
266  'uid' => 42,
267  ],
268  'recordTypeValue' => 'aType',
269  'processedTca' => [
270  'types' => [
271  'aType' => [
272  'showitem' => 'aField',
273  ],
274  ],
275  'columns' => [
276  'aField' => [
277  'config' => [
278  'type' => 'input',
279  ]
280  ],
281  ],
282  ],
283  'inlineParentConfig' => [
284  'foreign_table' => 'aTable',
285  ],
286  'isInlineChild' => true,
287  'isInlineAjaxOpeningContext' => false,
288  'inlineExpandCollapseStateArray' => [
289  'aTable' => [
290  42,
291  ],
292  ],
293  ];
294  $expected = $input;
295  $expected['columnsToProcess'] = ['aField'];
296  $this->assertSame($expected, $this->subject->addData($input));
297  }
298 
303  {
304  $input = [
305  'command' => 'edit',
306  'databaseRow' => [
307  'uid' => 42,
308  ],
309  'recordTypeValue' => 'aType',
310  'processedTca' => [
311  'types' => [
312  'aType' => [
313  'showitem' => 'aField',
314  ],
315  ],
316  'columns' => [
317  'aField' => [
318  'config' => [
319  'type' => 'input',
320  ]
321  ],
322  ],
323  ],
324  'inlineParentConfig' => [
325  'foreign_table' => 'aTable',
326  'appearance' => [
327  'collapseAll' => true,
328  ],
329  ],
330  'isInlineChild' => true,
331  'isInlineAjaxOpeningContext' => true,
332  'inlineExpandCollapseStateArray' => [],
333  ];
334  $expected = $input;
335  $expected['columnsToProcess'] = [ 'aField' ];
336  $this->assertSame($expected, $this->subject->addData($input));
337  }
338 
343  {
344  $input = [
345  'command' => 'new',
346  'databaseRow' => [
347  'uid' => 'NEW1234',
348  ],
349  'recordTypeValue' => 'aType',
350  'processedTca' => [
351  'types' => [
352  'aType' => [
353  'showitem' => 'aField',
354  ],
355  ],
356  'columns' => [
357  'aField' => [
358  'config' => [
359  'type' => 'input',
360  ]
361  ],
362  ],
363  ],
364  'inlineParentConfig' => [
365  'foreign_table' => 'aTable',
366  'appearance' => [
367  'collapseAll' => true,
368  ],
369  ],
370  'isInlineChild' => true,
371  'isInlineAjaxOpeningContext' => false,
372  'inlineExpandCollapseStateArray' => [],
373  ];
374  $expected = $input;
375  $expected['columnsToProcess'] = [ 'aField' ];
376  $this->assertSame($expected, $this->subject->addData($input));
377  }
378 
379 }