TYPO3 CMS  TYPO3_8-7
TcaInlineExpandCollapseStateTest.php
Go to the documentation of this file.
1 <?php
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 
18 
22 class TcaInlineExpandCollapseStateTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
27  protected $subject;
28 
29  protected function setUp()
30  {
31  $this->subject = new TcaInlineExpandCollapseState();
32  }
33 
38  {
39  $input = [
40  'command' => 'edit',
41  'tableName' => 'aParentTable',
42  'databaseRow' => [
43  'uid' => 5,
44  ],
45  ];
46  $inlineState = [
47  'aParentTable' => [
48  5 => [
49  'aChildTable' => [
50  // Records 23 and 42 are expanded
51  23,
52  42,
53  ],
54  ],
55  ],
56  ];
57  $GLOBALS['BE_USER'] = new \stdClass();
58  $GLOBALS['BE_USER']->uc = [
59  'inlineView' => serialize($inlineState),
60  ];
61  $expected = $input;
62  $expected['inlineExpandCollapseStateArray'] = $inlineState['aParentTable'][5];
63  $this->assertSame($expected, $this->subject->addData($input));
64  }
65 
70  {
71  $input = [
72  'command' => 'edit',
73  'tableName' => 'bChildTable',
74  'databaseRow' => [
75  'uid' => 13,
76  ],
77  'inlineTopMostParentTableName' => 'aParentTable',
78  'inlineTopMostParentUid' => 5,
79  ];
80  $inlineState = [
81  'aParentTable' => [
82  5 => [
83  'aChildTable' => [
84  // Records 23 and 42 are expanded
85  23,
86  42,
87  ],
88  'bChildTable' => [
89  // Records 13 and 66 are expanded
90  13,
91  66,
92  ],
93  ],
94  ],
95  ];
96  $GLOBALS['BE_USER'] = new \stdClass();
97  $GLOBALS['BE_USER']->uc = [
98  'inlineView' => serialize($inlineState),
99  ];
100  $expected = $input;
101  $expected['inlineExpandCollapseStateArray'] = $inlineState['aParentTable'][5];
102  $this->assertSame($expected, $this->subject->addData($input));
103  }
104 
109  {
110  return [
111  'Inline child is expanded because of state in expandCollapseStateArray' => [
112  [
113  'command' => 'edit',
114  'databaseRow' => [
115  'uid' => 42,
116  ],
117  'recordTypeValue' => 'aType',
118  'processedTca' => [
119  'types' => [
120  'aType' => [
121  'showitem' => 'aField',
122  ],
123  ],
124  'columns' => [
125  'aField' => [
126  'config' => [
127  'type' => 'input',
128  ]
129  ],
130  ],
131  ],
132  'inlineParentConfig' => [
133  'foreign_table' => 'aTable',
134  ],
135  'isInlineChild' => true,
136  'isInlineChildExpanded' => false,
137  'isInlineAjaxOpeningContext' => false,
138  'inlineExpandCollapseStateArray' => [
139  'aTable' => [
140  42,
141  ],
142  ],
143  ],
144  true
145  ],
146  'Inline child is expanded because of ajax opening context' => [
147  [
148  'command' => 'edit',
149  'databaseRow' => [
150  'uid' => 42,
151  ],
152  'recordTypeValue' => 'aType',
153  'processedTca' => [
154  'types' => [
155  'aType' => [
156  'showitem' => 'aField',
157  ],
158  ],
159  'columns' => [
160  'aField' => [
161  'config' => [
162  'type' => 'input',
163  ]
164  ],
165  ],
166  ],
167  'inlineParentConfig' => [
168  'foreign_table' => 'aTable',
169  'appearance' => [
170  'collapseAll' => true,
171  ],
172  ],
173  'isInlineChild' => true,
174  'isInlineChildExpanded' => false,
175  'isInlineAjaxOpeningContext' => true,
176  'inlineExpandCollapseStateArray' => [],
177  ],
178  true
179  ],
180  'Inline child is collapsed because of collapseAll' => [
181  [
182  'command' => 'edit',
183  'databaseRow' => [
184  'uid' => 42,
185  ],
186  'recordTypeValue' => 'aType',
187  'processedTca' => [
188  'types' => [
189  'aType' => [
190  'showitem' => 'aField',
191  ],
192  ],
193  'columns' => [
194  'aField' => [
195  'config' => [
196  'type' => 'input',
197  ]
198  ],
199  ],
200  ],
201  'inlineParentConfig' => [
202  'foreign_table' => 'aTable',
203  'appearance' => [
204  'collapseAll' => true,
205  ],
206  ],
207  'isInlineChild' => true,
208  'isInlineChildExpanded' => false,
209  'inlineExpandCollapseStateArray' => [],
210  ],
211  false
212  ],
213  'Inline child is expanded because of expandAll (inverse collapseAll setting)' => [
214  [
215  'command' => 'edit',
216  'databaseRow' => [
217  'uid' => 42,
218  ],
219  'recordTypeValue' => 'aType',
220  'processedTca' => [
221  'types' => [
222  'aType' => [
223  'showitem' => 'aField',
224  ],
225  ],
226  'columns' => [
227  'aField' => [
228  'config' => [
229  'type' => 'input',
230  ]
231  ],
232  ],
233  ],
234  'inlineParentConfig' => [
235  'foreign_table' => 'aTable',
236  'appearance' => [
237  'collapseAll' => false,
238  ],
239  ],
240  'isInlineChild' => true,
241  'isInlineChildExpanded' => false,
242  'inlineExpandCollapseStateArray' => [],
243  ],
244  true
245  ],
246  'New inline child is expanded' => [
247  [
248  'command' => 'new',
249  'databaseRow' => [
250  'uid' => 'NEW1234',
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  'appearance' => [
270  'collapseAll' => true,
271  ],
272  ],
273  'isInlineChild' => true,
274  'isInlineChildExpanded' => false,
275  'isInlineAjaxOpeningContext' => false,
276  'inlineExpandCollapseStateArray' => [],
277  ],
278  true
279  ],
280  'Inline child marked as expanded stays expanded (e.g. combination child)' => [
281  [
282  'command' => 'edit',
283  'databaseRow' => [
284  'uid' => 42,
285  ],
286  'recordTypeValue' => 'aType',
287  'processedTca' => [
288  'types' => [
289  'aType' => [
290  'showitem' => 'aField',
291  ],
292  ],
293  'columns' => [
294  'aField' => [
295  'config' => [
296  'type' => 'input',
297  ]
298  ],
299  ],
300  ],
301  'inlineParentConfig' => [
302  'foreign_table' => 'aTable',
303  'appearance' => [
304  'collapseAll' => true,
305  ],
306  ],
307  'isInlineChild' => true,
308  'isInlineChildExpanded' => true,
309  'inlineExpandCollapseStateArray' => [],
310  ],
311  true
312  ],
313  ];
314  }
315 
323  public function addDataAddsCorrectIsInlineChildExpanded(array $input, $expectedIsInlineChildExpanded)
324  {
325  $expected = $input;
326  $expected['isInlineChildExpanded'] = $expectedIsInlineChildExpanded;
327  $this->assertSame($expected, $this->subject->addData($input));
328  }
329 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']