TYPO3 CMS  TYPO3_7-6
InlineStackProcessorTest.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 
20 
25 {
26  protected function setUp()
27  {
28  // @todo: Remove if stack processor does not fiddle with tsConfig anymore and no longer sets 'config'
29  $dbProphecy = $this->prophesize(DatabaseConnection::class);
30  $GLOBALS['TYPO3_DB'] = $dbProphecy->reveal();
31  }
32 
37  {
38  return [
39  'simple 1-level table structure' => [
40  'data-pageId-childTable',
41  [
42  'unstable' => [
43  'table' => 'childTable',
44  ],
45  ],
46  []
47  ],
48  'simple 1-level table-uid structure' => [
49  'data-pageId-childTable-childUid',
50  [
51  'unstable' => [
52  'table' => 'childTable',
53  'uid' => 'childUid',
54  ],
55  ],
56  []
57  ],
58  'simple 1-level table-uid-field structure' => [
59  'data-pageId-childTable-childUid-childField',
60  [
61  'unstable' => [
62  'table' => 'childTable',
63  'uid' => 'childUid',
64  'field' => 'childField',
65  ],
66  ],
67  [],
68  ],
69  'simple 2-level table structure' => [
70  'data-pageId-parentTable-parentUid-parentField-childTable',
71  [
72  'stable' => [
73  [
74  'table' => 'parentTable',
75  'uid' => 'parentUid',
76  'field' => 'parentField',
77  'config' => null,
78  'localizationMode' => false,
79  ],
80  ],
81  'unstable' => [
82  'table' => 'childTable',
83  ],
84  ],
85  [
86  'form' => 'data[parentTable][parentUid][parentField]',
87  'object' => 'data-pageId-parentTable-parentUid-parentField',
88  ],
89  ],
90  'simple 2-level table-uid structure' => [
91  'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
92  [
93  'stable' => [
94  [
95  'table' => 'parentTable',
96  'uid' => 'parentUid',
97  'field' => 'parentField',
98  'config' => null,
99  'localizationMode' => false,
100  ],
101  ],
102  'unstable' => [
103  'table' => 'childTable',
104  'uid' => 'childUid',
105  ],
106  ],
107  [
108  'form' => 'data[parentTable][parentUid][parentField]',
109  'object' => 'data-pageId-parentTable-parentUid-parentField',
110  ],
111  ],
112  'simple 2-level table-uid-field structure' => [
113  'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
114  [
115  'stable' => [
116  [
117  'table' => 'parentTable',
118  'uid' => 'parentUid',
119  'field' => 'parentField',
120  'config' => null,
121  'localizationMode' => false,
122  ],
123  ],
124  'unstable' => [
125  'table' => 'childTable',
126  'uid' => 'childUid',
127  'field' => 'childField',
128  ],
129  ],
130  [
131  'form' => 'data[parentTable][parentUid][parentField]',
132  'object' => 'data-pageId-parentTable-parentUid-parentField',
133  ],
134  ],
135  'simple 3-level table structure' => [
136  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
137  [
138  'stable' => [
139  [
140  'table' => 'grandParentTable',
141  'uid' => 'grandParentUid',
142  'field' => 'grandParentField',
143  'config' => null,
144  'localizationMode' => false,
145  ],
146  [
147  'table' => 'parentTable',
148  'uid' => 'parentUid',
149  'field' => 'parentField',
150  'config' => null,
151  'localizationMode' => false,
152  ],
153  ],
154  'unstable' => [
155  'table' => 'childTable',
156  ],
157  ],
158  [
159  'form' => 'data[parentTable][parentUid][parentField]',
160  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
161  ],
162  ],
163  'simple 3-level table-uid structure' => [
164  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
165  [
166  'stable' => [
167  [
168  'table' => 'grandParentTable',
169  'uid' => 'grandParentUid',
170  'field' => 'grandParentField',
171  'config' => null,
172  'localizationMode' => false,
173  ],
174  [
175  'table' => 'parentTable',
176  'uid' => 'parentUid',
177  'field' => 'parentField',
178  'config' => null,
179  'localizationMode' => false,
180  ],
181  ],
182  'unstable' => [
183  'table' => 'childTable',
184  'uid' => 'childUid',
185  ],
186  ],
187  [
188  'form' => 'data[parentTable][parentUid][parentField]',
189  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
190  ],
191  ],
192  'simple 3-level table-uid-field structure' => [
193  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
194  [
195  'stable' => [
196  [
197  'table' => 'grandParentTable',
198  'uid' => 'grandParentUid',
199  'field' => 'grandParentField',
200  'config' => null,
201  'localizationMode' => false,
202  ],
203  [
204  'table' => 'parentTable',
205  'uid' => 'parentUid',
206  'field' => 'parentField',
207  'config' => null,
208  'localizationMode' => false,
209  ],
210  ],
211  'unstable' => [
212  'table' => 'childTable',
213  'uid' => 'childUid',
214  'field' => 'childField',
215  ],
216  ],
217  [
218  'form' => 'data[parentTable][parentUid][parentField]',
219  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
220  ],
221  ],
222  'flexform 3-level table-uid structure' => [
223  'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField-childTable-childUid',
224  [
225  'stable' => [
226  [
227  'table' => 'grandParentTable',
228  'uid' => 'grandParentUid',
229  'field' => 'grandParentField',
230  'flexform' => [
231  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
232  ],
233  'config' => null,
234  'localizationMode' => false,
235  ],
236  [
237  'table' => 'parentTable',
238  'uid' => 'parentUid',
239  'field' => 'parentField',
240  'config' => null,
241  'localizationMode' => false,
242  ],
243  ],
244  'unstable' => [
245  'table' => 'childTable',
246  'uid' => 'childUid',
247  ],
248  ],
249  [
250  'form' => 'data[parentTable][parentUid][parentField]',
251  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField',
252  ],
253  ],
254  ];
255  }
256 
261  public function initializeByParsingDomObjectIdStringParsesStructureString($string, array $expectedInlineStructure, array $_)
262  {
264  $subject = $this->getAccessibleMock(InlineStackProcessor::class, ['dummy']);
265  $subject->initializeByParsingDomObjectIdString($string);
266  $structure = $subject->_get('inlineStructure');
267  $this->assertEquals($expectedInlineStructure, $structure);
268  }
269 
274  public function getCurrentStructureFormPrefixReturnsExceptedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
275  {
277  $subject = new InlineStackProcessor;
278  $subject->initializeByParsingDomObjectIdString($string);
279  $this->assertEquals($expectedFormName['form'], $subject->getCurrentStructureFormPrefix());
280  }
281 
286  public function getCurrentStructureDomObjectIdPrefixReturnsExceptedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
287  {
289  $subject = new InlineStackProcessor;
290  $subject->initializeByParsingDomObjectIdString($string);
291  $this->assertEquals($expectedFormName['object'], $subject->getCurrentStructureDomObjectIdPrefix('pageId'));
292  }
293 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']