‪TYPO3CMS  10.4
TcaInlineExpandCollapseStateTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪TcaInlineExpandCollapseStateTest extends UnitTestCase
26 {
31  {
32  $input = [
33  'command' => 'edit',
34  'tableName' => 'aParentTable',
35  'databaseRow' => [
36  'uid' => 5,
37  ],
38  'isInlineChildExpanded' => false,
39  'inlineParentConfig' => [
40  'foreign_table' => 'aTable',
41  ],
42  'isInlineAjaxOpeningContext' => false,
43  ];
44  $inlineState = [
45  'aParentTable' => [
46  5 => [
47  'aChildTable' => [
48  // Records 23 and 42 are expanded
49  23,
50  42,
51  ],
52  ],
53  ],
54  ];
55  ‪$GLOBALS['BE_USER'] = new \stdClass();
56  ‪$GLOBALS['BE_USER']->uc = [
57  'inlineView' => json_encode($inlineState),
58  ];
59  $expected = $input;
60  $expected['inlineExpandCollapseStateArray'] = $inlineState['aParentTable'][5];
61  self::assertSame($expected, (new ‪TcaInlineExpandCollapseState())->addData($input));
62  }
63 
68  {
69  $input = [
70  'command' => 'edit',
71  'tableName' => 'bChildTable',
72  'databaseRow' => [
73  'uid' => 13,
74  ],
75  'inlineTopMostParentTableName' => 'aParentTable',
76  'inlineTopMostParentUid' => 5,
77  'isInlineChildExpanded' => false,
78  'inlineParentConfig' => [
79  'foreign_table' => 'aTable',
80  ],
81  'isInlineAjaxOpeningContext' => false,
82  ];
83  $inlineState = [
84  'aParentTable' => [
85  5 => [
86  'aChildTable' => [
87  // Records 23 and 42 are expanded
88  23,
89  42,
90  ],
91  'bChildTable' => [
92  // Records 13 and 66 are expanded
93  13,
94  66,
95  ],
96  ],
97  ],
98  ];
99  ‪$GLOBALS['BE_USER'] = new \stdClass();
100  ‪$GLOBALS['BE_USER']->uc = [
101  'inlineView' => json_encode($inlineState),
102  ];
103  $expected = $input;
104  $expected['inlineExpandCollapseStateArray'] = $inlineState['aParentTable'][5];
105  self::assertSame($expected, (new ‪TcaInlineExpandCollapseState())->addData($input));
106  }
107 
112  {
113  return [
114  'Inline child is expanded because of state in expandCollapseStateArray' => [
115  [
116  'command' => 'edit',
117  'databaseRow' => [
118  'uid' => 42,
119  ],
120  'recordTypeValue' => 'aType',
121  'processedTca' => [
122  'types' => [
123  'aType' => [
124  'showitem' => 'aField',
125  ],
126  ],
127  'columns' => [
128  'aField' => [
129  'config' => [
130  'type' => 'input',
131  ]
132  ],
133  ],
134  ],
135  'inlineParentConfig' => [
136  'foreign_table' => 'aTable',
137  ],
138  'isInlineChild' => true,
139  'isInlineChildExpanded' => false,
140  'isInlineAjaxOpeningContext' => false,
141  'inlineExpandCollapseStateArray' => [
142  'aTable' => [
143  42,
144  ],
145  ],
146  ],
147  true
148  ],
149  'Inline child is expanded because of ajax opening context' => [
150  [
151  'command' => 'edit',
152  'tableName' => 'aParentTable',
153  'databaseRow' => [
154  'uid' => 42,
155  ],
156  'recordTypeValue' => 'aType',
157  'processedTca' => [
158  'types' => [
159  'aType' => [
160  'showitem' => 'aField',
161  ],
162  ],
163  'columns' => [
164  'aField' => [
165  'config' => [
166  'type' => 'input',
167  ]
168  ],
169  ],
170  ],
171  'inlineParentConfig' => [
172  'foreign_table' => 'aTable',
173  'appearance' => [
174  'collapseAll' => true,
175  ],
176  ],
177  'isInlineChild' => true,
178  'isInlineChildExpanded' => false,
179  'isInlineAjaxOpeningContext' => true,
180  'inlineExpandCollapseStateArray' => [],
181  ],
182  true
183  ],
184  'Inline child is collapsed because of collapseAll' => [
185  [
186  'command' => 'edit',
187  'tableName' => 'aParentTable',
188  'databaseRow' => [
189  'uid' => 42,
190  ],
191  'recordTypeValue' => 'aType',
192  'processedTca' => [
193  'types' => [
194  'aType' => [
195  'showitem' => 'aField',
196  ],
197  ],
198  'columns' => [
199  'aField' => [
200  'config' => [
201  'type' => 'input',
202  ]
203  ],
204  ],
205  ],
206  'inlineParentConfig' => [
207  'foreign_table' => 'aTable',
208  'appearance' => [
209  'collapseAll' => true,
210  ],
211  ],
212  'isInlineChild' => true,
213  'isInlineChildExpanded' => false,
214  'isInlineAjaxOpeningContext' => false,
215  'inlineExpandCollapseStateArray' => [],
216  ],
217  false
218  ],
219  'Inline child is expanded because of expandAll (inverse collapseAll setting)' => [
220  [
221  'command' => 'edit',
222  'tableName' => 'aParentTable',
223  'databaseRow' => [
224  'uid' => 42,
225  ],
226  'recordTypeValue' => 'aType',
227  'processedTca' => [
228  'types' => [
229  'aType' => [
230  'showitem' => 'aField',
231  ],
232  ],
233  'columns' => [
234  'aField' => [
235  'config' => [
236  'type' => 'input',
237  ]
238  ],
239  ],
240  ],
241  'inlineParentConfig' => [
242  'foreign_table' => 'aTable',
243  'appearance' => [
244  'collapseAll' => false,
245  ],
246  ],
247  'isInlineChild' => true,
248  'isInlineChildExpanded' => false,
249  'inlineExpandCollapseStateArray' => [],
250  ],
251  true
252  ],
253  'New inline child is expanded' => [
254  [
255  'command' => 'new',
256  'databaseRow' => [
257  'uid' => 'NEW1234',
258  ],
259  'recordTypeValue' => 'aType',
260  'processedTca' => [
261  'types' => [
262  'aType' => [
263  'showitem' => 'aField',
264  ],
265  ],
266  'columns' => [
267  'aField' => [
268  'config' => [
269  'type' => 'input',
270  ]
271  ],
272  ],
273  ],
274  'inlineParentConfig' => [
275  'foreign_table' => 'aTable',
276  'appearance' => [
277  'collapseAll' => true,
278  ],
279  ],
280  'isInlineChild' => true,
281  'isInlineChildExpanded' => false,
282  'isInlineAjaxOpeningContext' => false,
283  'inlineExpandCollapseStateArray' => [],
284  ],
285  true
286  ],
287  'Inline child marked as expanded stays expanded (e.g. combination child)' => [
288  [
289  'command' => 'edit',
290  'tableName' => 'aParentTable',
291  'databaseRow' => [
292  'uid' => 42,
293  ],
294  'recordTypeValue' => 'aType',
295  'processedTca' => [
296  'types' => [
297  'aType' => [
298  'showitem' => 'aField',
299  ],
300  ],
301  'columns' => [
302  'aField' => [
303  'config' => [
304  'type' => 'input',
305  ]
306  ],
307  ],
308  ],
309  'inlineParentConfig' => [
310  'foreign_table' => 'aTable',
311  'appearance' => [
312  'collapseAll' => true,
313  ],
314  ],
315  'isInlineChild' => true,
316  'isInlineChildExpanded' => true,
317  'inlineExpandCollapseStateArray' => [],
318  ],
319  true
320  ],
321  ];
322  }
323 
331  public function ‪addDataAddsCorrectIsInlineChildExpanded(array $input, $expectedIsInlineChildExpanded)
332  {
333  $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
334  ‪$GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
335 
336  $expected = $input;
337  $expected['isInlineChildExpanded'] = $expectedIsInlineChildExpanded;
338  self::assertSame($expected, (new ‪TcaInlineExpandCollapseState())->addData($input));
339  }
340 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineExpandCollapseStateTest
Definition: TcaInlineExpandCollapseStateTest.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineExpandCollapseStateTest\addDataAddsCorrectIsInlineChildExpandedDataProvider
‪array addDataAddsCorrectIsInlineChildExpandedDataProvider()
Definition: TcaInlineExpandCollapseStateTest.php:111
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineExpandCollapseStateTest\addDataAddsInlineStatusForTableUid
‪addDataAddsInlineStatusForTableUid()
Definition: TcaInlineExpandCollapseStateTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineExpandCollapseStateTest\addDataAddsCorrectIsInlineChildExpanded
‪addDataAddsCorrectIsInlineChildExpanded(array $input, $expectedIsInlineChildExpanded)
Definition: TcaInlineExpandCollapseStateTest.php:331
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineExpandCollapseStateTest\addDataAddsInlineStatusForSecondLevelChild
‪addDataAddsInlineStatusForSecondLevelChild()
Definition: TcaInlineExpandCollapseStateTest.php:67
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState
Definition: TcaInlineExpandCollapseState.php:26