TYPO3 CMS  TYPO3_6-2
InlineElementTest.php
Go to the documentation of this file.
1 <?php
3 
26  protected $subject;
27 
31  protected function setUp() {
32  // @todo Use $this->buildAccessibleProxy() if properties are protected
33  $this->subject = new \TYPO3\CMS\Backend\Form\Element\InlineElement();
34  $this->subject->fObj = $this->getMock('TYPO3\\CMS\\Backend\\Form\\FormEngine', array(), array(), '', FALSE);
35  }
36 
44  public function pushStructureFillsInlineStructure(array $arguments, array $expectedInlineStructure, array $expectedInlineNames) {
45  $this->subject->inlineFirstPid = 'pageId';
46 
47  call_user_func_array(array($this->subject, 'pushStructure'), $arguments);
48 
49  $this->assertEquals($expectedInlineStructure, $this->subject->inlineStructure);
50  $this->assertEquals($expectedInlineNames, $this->subject->inlineNames);
51  }
52 
54  return array(
55  'regular field' => array(
56  array(
57  'parentTable',
58  'parentUid',
59  'parentField'
60  ),
61  array(
62  'stable' => array(
63  array(
64  'table' => 'parentTable',
65  'uid' => 'parentUid',
66  'field' => 'parentField',
67  'config' => array(),
68  'localizationMode' => FALSE,
69  ),
70  ),
71  ),
72  array(
73  'form' => '[parentTable][parentUid][parentField]',
74  'object' => 'data-pageId-parentTable-parentUid-parentField',
75  )
76  ),
77  'flexform field' => array(
78  array(
79  'parentTable',
80  'parentUid',
81  'parentField',
82  array(),
83  array(
84  'itemFormElName' => 'data[parentTable][parentUid][parentField][data][sDEF][lDEF][grandParentFlexForm][vDEF]'
85  )
86  ),
87  array(
88  'stable' => array(
89  array(
90  'table' => 'parentTable',
91  'uid' => 'parentUid',
92  'field' => 'parentField',
93  'config' => array(),
94  'localizationMode' => FALSE,
95  'flexform' => array(
96  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
97  ),
98  ),
99  ),
100  ),
101  array(
102  'form' => '[parentTable][parentUid][parentField][data][sDEF][lDEF][grandParentFlexForm][vDEF]',
103  'object' => 'data-pageId-parentTable-parentUid-parentField---data---sDEF---lDEF---grandParentFlexForm---vDEF',
104  )
105  ),
106  );
107  }
108 
116  public function structureStringIsParsed($string, array $expectedInlineStructure, array $expectedInlineNames) {
117  $this->subject->parseStructureString($string, FALSE);
118 
119  $this->assertEquals('pageId', $this->subject->inlineFirstPid);
120  $this->assertEquals($expectedInlineStructure, $this->subject->inlineStructure);
121  $this->assertEquals($expectedInlineNames, $this->subject->inlineNames);
122  }
123 
128  return array(
129  'simple 1-level table structure' => array(
130  'data-pageId-childTable',
131  array(
132  'unstable' => array(
133  'table' => 'childTable',
134  ),
135  ),
136  array()
137  ),
138  'simple 1-level table-uid structure' => array(
139  'data-pageId-childTable-childUid',
140  array(
141  'unstable' => array(
142  'table' => 'childTable',
143  'uid' => 'childUid',
144  ),
145  ),
146  array()
147  ),
148  'simple 1-level table-uid-field structure' => array(
149  'data-pageId-childTable-childUid-childField',
150  array(
151  'unstable' => array(
152  'table' => 'childTable',
153  'uid' => 'childUid',
154  'field' => 'childField',
155  ),
156  ),
157  array(),
158  ),
159  'simple 2-level table structure' => array(
160  'data-pageId-parentTable-parentUid-parentField-childTable',
161  array(
162  'stable' => array(
163  array(
164  'table' => 'parentTable',
165  'uid' => 'parentUid',
166  'field' => 'parentField',
167  ),
168  ),
169  'unstable' => array(
170  'table' => 'childTable',
171  ),
172  ),
173  array(
174  'form' => '[parentTable][parentUid][parentField]',
175  'object' => 'data-pageId-parentTable-parentUid-parentField',
176  ),
177  ),
178  'simple 2-level table-uid structure' => array(
179  'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
180  array(
181  'stable' => array(
182  array(
183  'table' => 'parentTable',
184  'uid' => 'parentUid',
185  'field' => 'parentField',
186  ),
187  ),
188  'unstable' => array(
189  'table' => 'childTable',
190  'uid' => 'childUid',
191  ),
192  ),
193  array(
194  'form' => '[parentTable][parentUid][parentField]',
195  'object' => 'data-pageId-parentTable-parentUid-parentField',
196  ),
197  ),
198  'simple 2-level table-uid-field structure' => array(
199  'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
200  array(
201  'stable' => array(
202  array(
203  'table' => 'parentTable',
204  'uid' => 'parentUid',
205  'field' => 'parentField',
206  ),
207  ),
208  'unstable' => array(
209  'table' => 'childTable',
210  'uid' => 'childUid',
211  'field' => 'childField',
212  ),
213  ),
214  array(
215  'form' => '[parentTable][parentUid][parentField]',
216  'object' => 'data-pageId-parentTable-parentUid-parentField',
217  ),
218  ),
219  'simple 3-level table structure' => array(
220  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
221  array(
222  'stable' => array(
223  array(
224  'table' => 'grandParentTable',
225  'uid' => 'grandParentUid',
226  'field' => 'grandParentField',
227  ),
228  array(
229  'table' => 'parentTable',
230  'uid' => 'parentUid',
231  'field' => 'parentField',
232  ),
233  ),
234  'unstable' => array(
235  'table' => 'childTable',
236  ),
237  ),
238  array(
239  'form' => '[parentTable][parentUid][parentField]',
240  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
241  ),
242  ),
243  'simple 3-level table-uid structure' => array(
244  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
245  array(
246  'stable' => array(
247  array(
248  'table' => 'grandParentTable',
249  'uid' => 'grandParentUid',
250  'field' => 'grandParentField',
251  ),
252  array(
253  'table' => 'parentTable',
254  'uid' => 'parentUid',
255  'field' => 'parentField',
256  ),
257  ),
258  'unstable' => array(
259  'table' => 'childTable',
260  'uid' => 'childUid',
261  ),
262  ),
263  array(
264  'form' => '[parentTable][parentUid][parentField]',
265  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
266  ),
267  ),
268  'simple 3-level table-uid-field structure' => array(
269  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
270  array(
271  'stable' => array(
272  array(
273  'table' => 'grandParentTable',
274  'uid' => 'grandParentUid',
275  'field' => 'grandParentField',
276  ),
277  array(
278  'table' => 'parentTable',
279  'uid' => 'parentUid',
280  'field' => 'parentField',
281  ),
282  ),
283  'unstable' => array(
284  'table' => 'childTable',
285  'uid' => 'childUid',
286  'field' => 'childField',
287  ),
288  ),
289  array(
290  'form' => '[parentTable][parentUid][parentField]',
291  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
292  ),
293  ),
294  'flexform 3-level table-uid structure' => array(
295  'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField-childTable-childUid',
296  array(
297  'stable' => array(
298  array(
299  'table' => 'grandParentTable',
300  'uid' => 'grandParentUid',
301  'field' => 'grandParentField',
302  'flexform' => array(
303  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
304  ),
305  ),
306  array(
307  'table' => 'parentTable',
308  'uid' => 'parentUid',
309  'field' => 'parentField',
310  ),
311  ),
312  'unstable' => array(
313  'table' => 'childTable',
314  'uid' => 'childUid',
315  ),
316  ),
317  array(
318  'form' => '[parentTable][parentUid][parentField]',
319  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField',
320  ),
321  ),
322  );
323  }
324 }
pushStructureFillsInlineStructure(array $arguments, array $expectedInlineStructure, array $expectedInlineNames)
structureStringIsParsed($string, array $expectedInlineStructure, array $expectedInlineNames)