TYPO3  7.6
InlineStackProcessorTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form;
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 use TYPO3\CMS\Core\Tests\UnitTestCase;
20 
24 class InlineStackProcessorTest extends UnitTestCase
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 array(
39  'simple 1-level table structure' => array(
40  'data-pageId-childTable',
41  array(
42  'unstable' => array(
43  'table' => 'childTable',
44  ),
45  ),
46  array()
47  ),
48  'simple 1-level table-uid structure' => array(
49  'data-pageId-childTable-childUid',
50  array(
51  'unstable' => array(
52  'table' => 'childTable',
53  'uid' => 'childUid',
54  ),
55  ),
56  array()
57  ),
58  'simple 1-level table-uid-field structure' => array(
59  'data-pageId-childTable-childUid-childField',
60  array(
61  'unstable' => array(
62  'table' => 'childTable',
63  'uid' => 'childUid',
64  'field' => 'childField',
65  ),
66  ),
67  array(),
68  ),
69  'simple 2-level table structure' => array(
70  'data-pageId-parentTable-parentUid-parentField-childTable',
71  array(
72  'stable' => array(
73  array(
74  'table' => 'parentTable',
75  'uid' => 'parentUid',
76  'field' => 'parentField',
77  'config' => null,
78  'localizationMode' => false,
79  ),
80  ),
81  'unstable' => array(
82  'table' => 'childTable',
83  ),
84  ),
85  array(
86  'form' => 'data[parentTable][parentUid][parentField]',
87  'object' => 'data-pageId-parentTable-parentUid-parentField',
88  ),
89  ),
90  'simple 2-level table-uid structure' => array(
91  'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
92  array(
93  'stable' => array(
94  array(
95  'table' => 'parentTable',
96  'uid' => 'parentUid',
97  'field' => 'parentField',
98  'config' => null,
99  'localizationMode' => false,
100  ),
101  ),
102  'unstable' => array(
103  'table' => 'childTable',
104  'uid' => 'childUid',
105  ),
106  ),
107  array(
108  'form' => 'data[parentTable][parentUid][parentField]',
109  'object' => 'data-pageId-parentTable-parentUid-parentField',
110  ),
111  ),
112  'simple 2-level table-uid-field structure' => array(
113  'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
114  array(
115  'stable' => array(
116  array(
117  'table' => 'parentTable',
118  'uid' => 'parentUid',
119  'field' => 'parentField',
120  'config' => null,
121  'localizationMode' => false,
122  ),
123  ),
124  'unstable' => array(
125  'table' => 'childTable',
126  'uid' => 'childUid',
127  'field' => 'childField',
128  ),
129  ),
130  array(
131  'form' => 'data[parentTable][parentUid][parentField]',
132  'object' => 'data-pageId-parentTable-parentUid-parentField',
133  ),
134  ),
135  'simple 3-level table structure' => array(
136  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
137  array(
138  'stable' => array(
139  array(
140  'table' => 'grandParentTable',
141  'uid' => 'grandParentUid',
142  'field' => 'grandParentField',
143  'config' => null,
144  'localizationMode' => false,
145  ),
146  array(
147  'table' => 'parentTable',
148  'uid' => 'parentUid',
149  'field' => 'parentField',
150  'config' => null,
151  'localizationMode' => false,
152  ),
153  ),
154  'unstable' => array(
155  'table' => 'childTable',
156  ),
157  ),
158  array(
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' => array(
164  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
165  array(
166  'stable' => array(
167  array(
168  'table' => 'grandParentTable',
169  'uid' => 'grandParentUid',
170  'field' => 'grandParentField',
171  'config' => null,
172  'localizationMode' => false,
173  ),
174  array(
175  'table' => 'parentTable',
176  'uid' => 'parentUid',
177  'field' => 'parentField',
178  'config' => null,
179  'localizationMode' => false,
180  ),
181  ),
182  'unstable' => array(
183  'table' => 'childTable',
184  'uid' => 'childUid',
185  ),
186  ),
187  array(
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' => array(
193  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
194  array(
195  'stable' => array(
196  array(
197  'table' => 'grandParentTable',
198  'uid' => 'grandParentUid',
199  'field' => 'grandParentField',
200  'config' => null,
201  'localizationMode' => false,
202  ),
203  array(
204  'table' => 'parentTable',
205  'uid' => 'parentUid',
206  'field' => 'parentField',
207  'config' => null,
208  'localizationMode' => false,
209  ),
210  ),
211  'unstable' => array(
212  'table' => 'childTable',
213  'uid' => 'childUid',
214  'field' => 'childField',
215  ),
216  ),
217  array(
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' => array(
223  'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField-childTable-childUid',
224  array(
225  'stable' => array(
226  array(
227  'table' => 'grandParentTable',
228  'uid' => 'grandParentUid',
229  'field' => 'grandParentField',
230  'flexform' => array(
231  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
232  ),
233  'config' => null,
234  'localizationMode' => false,
235  ),
236  array(
237  'table' => 'parentTable',
238  'uid' => 'parentUid',
239  'field' => 'parentField',
240  'config' => null,
241  'localizationMode' => false,
242  ),
243  ),
244  'unstable' => array(
245  'table' => 'childTable',
246  'uid' => 'childUid',
247  ),
248  ),
249  array(
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, array('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 }