TYPO3 CMS  TYPO3_8-7
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 
18 
22 class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
24 
29  {
30  return [
31  'simple 1-level table structure' => [
32  'data-pageId-childTable',
33  [
34  'unstable' => [
35  'table' => 'childTable',
36  ],
37  ],
38  []
39  ],
40  'simple 1-level table-uid structure' => [
41  'data-pageId-childTable-childUid',
42  [
43  'unstable' => [
44  'table' => 'childTable',
45  'uid' => 'childUid',
46  ],
47  ],
48  []
49  ],
50  'simple 1-level table-uid-field structure' => [
51  'data-pageId-childTable-childUid-childField',
52  [
53  'unstable' => [
54  'table' => 'childTable',
55  'uid' => 'childUid',
56  'field' => 'childField',
57  ],
58  ],
59  [],
60  ],
61  'simple 2-level table structure' => [
62  'data-pageId-parentTable-parentUid-parentField-childTable',
63  [
64  'stable' => [
65  [
66  'table' => 'parentTable',
67  'uid' => 'parentUid',
68  'field' => 'parentField',
69  'config' => null,
70  'localizationMode' => false,
71  ],
72  ],
73  'unstable' => [
74  'table' => 'childTable',
75  ],
76  ],
77  [
78  'form' => 'data[parentTable][parentUid][parentField]',
79  'object' => 'data-pageId-parentTable-parentUid-parentField',
80  ],
81  ],
82  'simple 2-level table-uid structure' => [
83  'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
84  [
85  'stable' => [
86  [
87  'table' => 'parentTable',
88  'uid' => 'parentUid',
89  'field' => 'parentField',
90  'config' => null,
91  'localizationMode' => false,
92  ],
93  ],
94  'unstable' => [
95  'table' => 'childTable',
96  'uid' => 'childUid',
97  ],
98  ],
99  [
100  'form' => 'data[parentTable][parentUid][parentField]',
101  'object' => 'data-pageId-parentTable-parentUid-parentField',
102  ],
103  ],
104  'simple 2-level table-uid-field structure' => [
105  'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
106  [
107  'stable' => [
108  [
109  'table' => 'parentTable',
110  'uid' => 'parentUid',
111  'field' => 'parentField',
112  'config' => null,
113  'localizationMode' => false,
114  ],
115  ],
116  'unstable' => [
117  'table' => 'childTable',
118  'uid' => 'childUid',
119  'field' => 'childField',
120  ],
121  ],
122  [
123  'form' => 'data[parentTable][parentUid][parentField]',
124  'object' => 'data-pageId-parentTable-parentUid-parentField',
125  ],
126  ],
127  'simple 3-level table structure' => [
128  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
129  [
130  'stable' => [
131  [
132  'table' => 'grandParentTable',
133  'uid' => 'grandParentUid',
134  'field' => 'grandParentField',
135  'config' => null,
136  'localizationMode' => false,
137  ],
138  [
139  'table' => 'parentTable',
140  'uid' => 'parentUid',
141  'field' => 'parentField',
142  'config' => null,
143  'localizationMode' => false,
144  ],
145  ],
146  'unstable' => [
147  'table' => 'childTable',
148  ],
149  ],
150  [
151  'form' => 'data[parentTable][parentUid][parentField]',
152  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
153  ],
154  ],
155  'simple 3-level table-uid structure' => [
156  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
157  [
158  'stable' => [
159  [
160  'table' => 'grandParentTable',
161  'uid' => 'grandParentUid',
162  'field' => 'grandParentField',
163  'config' => null,
164  'localizationMode' => false,
165  ],
166  [
167  'table' => 'parentTable',
168  'uid' => 'parentUid',
169  'field' => 'parentField',
170  'config' => null,
171  'localizationMode' => false,
172  ],
173  ],
174  'unstable' => [
175  'table' => 'childTable',
176  'uid' => 'childUid',
177  ],
178  ],
179  [
180  'form' => 'data[parentTable][parentUid][parentField]',
181  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
182  ],
183  ],
184  'simple 3-level table-uid-field structure' => [
185  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
186  [
187  'stable' => [
188  [
189  'table' => 'grandParentTable',
190  'uid' => 'grandParentUid',
191  'field' => 'grandParentField',
192  'config' => null,
193  'localizationMode' => false,
194  ],
195  [
196  'table' => 'parentTable',
197  'uid' => 'parentUid',
198  'field' => 'parentField',
199  'config' => null,
200  'localizationMode' => false,
201  ],
202  ],
203  'unstable' => [
204  'table' => 'childTable',
205  'uid' => 'childUid',
206  'field' => 'childField',
207  ],
208  ],
209  [
210  'form' => 'data[parentTable][parentUid][parentField]',
211  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
212  ],
213  ],
214  'flexform 3-level table-uid structure' => [
215  'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField-childTable-childUid',
216  [
217  'stable' => [
218  [
219  'table' => 'grandParentTable',
220  'uid' => 'grandParentUid',
221  'field' => 'grandParentField',
222  'flexform' => [
223  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
224  ],
225  'config' => null,
226  'localizationMode' => false,
227  ],
228  [
229  'table' => 'parentTable',
230  'uid' => 'parentUid',
231  'field' => 'parentField',
232  'config' => null,
233  'localizationMode' => false,
234  ],
235  ],
236  'unstable' => [
237  'table' => 'childTable',
238  'uid' => 'childUid',
239  ],
240  ],
241  [
242  'form' => 'data[parentTable][parentUid][parentField]',
243  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField',
244  ],
245  ],
246  ];
247  }
248 
253  public function initializeByParsingDomObjectIdStringParsesStructureString($string, array $expectedInlineStructure, array $_)
254  {
256  $subject = $this->getAccessibleMock(InlineStackProcessor::class, ['dummy']);
257  $subject->initializeByParsingDomObjectIdString($string);
258  $structure = $subject->_get('inlineStructure');
259  $this->assertEquals($expectedInlineStructure, $structure);
260  }
261 
266  public function getCurrentStructureFormPrefixReturnsExceptedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
267  {
269  $subject = new InlineStackProcessor;
270  $subject->initializeByParsingDomObjectIdString($string);
271  $this->assertEquals($expectedFormName['form'], $subject->getCurrentStructureFormPrefix());
272  }
273 
278  public function getCurrentStructureDomObjectIdPrefixReturnsExceptedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
279  {
281  $subject = new InlineStackProcessor;
282  $subject->initializeByParsingDomObjectIdString($string);
283  $this->assertEquals($expectedFormName['object'], $subject->getCurrentStructureDomObjectIdPrefix('pageId'));
284  }
285 }