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