‪TYPO3CMS  9.5
InlineStackProcessorTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Prophecy\Argument;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪InlineStackProcessorTest extends UnitTestCase
29 {
33  protected ‪$resetSingletonInstances = true;
34 
38  public function ‪setUp()
39  {
40  parent::setUp();
41  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
42  $cacheProphecy = $this->prophesize(FrontendInterface::class);
43  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
44  $cacheProphecy->get(Argument::cetera())->willReturn(false);
45  $cacheProphecy->set(Argument::cetera())->willReturn(false);
46  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
47  }
48 
53  {
54  return [
55  'simple 1-level table structure' => [
56  'data-pageId-childTable',
57  [
58  'unstable' => [
59  'table' => 'childTable',
60  ],
61  ],
62  [
63  'form' => '',
64  'object' => '',
65  ]
66  ],
67  'simple 1-level table-uid structure' => [
68  'data-pageId-childTable-childUid',
69  [
70  'unstable' => [
71  'table' => 'childTable',
72  'uid' => 'childUid',
73  ],
74  ],
75  [
76  'form' => '',
77  'object' => '',
78  ]
79  ],
80  'simple 1-level table-uid-field structure' => [
81  'data-pageId-childTable-childUid-childField',
82  [
83  'unstable' => [
84  'table' => 'childTable',
85  'uid' => 'childUid',
86  'field' => 'childField',
87  ],
88  ],
89  [
90  'form' => '',
91  'object' => '',
92  ],
93  ],
94  'simple 2-level table structure' => [
95  'data-pageId-parentTable-parentUid-parentField-childTable',
96  [
97  'stable' => [
98  [
99  'table' => 'parentTable',
100  'uid' => 'parentUid',
101  'field' => 'parentField',
102  'config' => [],
103  ],
104  ],
105  'unstable' => [
106  'table' => 'childTable',
107  ],
108  ],
109  [
110  'form' => 'data[parentTable][parentUid][parentField]',
111  'object' => 'data-pageId-parentTable-parentUid-parentField',
112  ],
113  ],
114  'simple 2-level table-uid structure' => [
115  'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
116  [
117  'stable' => [
118  [
119  'table' => 'parentTable',
120  'uid' => 'parentUid',
121  'field' => 'parentField',
122  'config' => [],
123  ],
124  ],
125  'unstable' => [
126  'table' => 'childTable',
127  'uid' => 'childUid',
128  ],
129  ],
130  [
131  'form' => 'data[parentTable][parentUid][parentField]',
132  'object' => 'data-pageId-parentTable-parentUid-parentField',
133  ],
134  ],
135  'simple 2-level table-uid-field structure' => [
136  'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
137  [
138  'stable' => [
139  [
140  'table' => 'parentTable',
141  'uid' => 'parentUid',
142  'field' => 'parentField',
143  'config' => [],
144  ],
145  ],
146  'unstable' => [
147  'table' => 'childTable',
148  'uid' => 'childUid',
149  'field' => 'childField',
150  ],
151  ],
152  [
153  'form' => 'data[parentTable][parentUid][parentField]',
154  'object' => 'data-pageId-parentTable-parentUid-parentField',
155  ],
156  ],
157  'simple 3-level table structure' => [
158  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
159  [
160  'stable' => [
161  [
162  'table' => 'grandParentTable',
163  'uid' => 'grandParentUid',
164  'field' => 'grandParentField',
165  'config' => [],
166  ],
167  [
168  'table' => 'parentTable',
169  'uid' => 'parentUid',
170  'field' => 'parentField',
171  'config' => [],
172  ],
173  ],
174  'unstable' => [
175  'table' => 'childTable',
176  ],
177  ],
178  [
179  'form' => 'data[parentTable][parentUid][parentField]',
180  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
181  ],
182  ],
183  'simple 3-level table-uid structure' => [
184  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
185  [
186  'stable' => [
187  [
188  'table' => 'grandParentTable',
189  'uid' => 'grandParentUid',
190  'field' => 'grandParentField',
191  'config' => [],
192  ],
193  [
194  'table' => 'parentTable',
195  'uid' => 'parentUid',
196  'field' => 'parentField',
197  'config' => [],
198  ],
199  ],
200  'unstable' => [
201  'table' => 'childTable',
202  'uid' => 'childUid',
203  ],
204  ],
205  [
206  'form' => 'data[parentTable][parentUid][parentField]',
207  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
208  ],
209  ],
210  'simple 3-level table-uid-field structure' => [
211  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
212  [
213  'stable' => [
214  [
215  'table' => 'grandParentTable',
216  'uid' => 'grandParentUid',
217  'field' => 'grandParentField',
218  'config' => [],
219  ],
220  [
221  'table' => 'parentTable',
222  'uid' => 'parentUid',
223  'field' => 'parentField',
224  'config' => [],
225  ],
226  ],
227  'unstable' => [
228  'table' => 'childTable',
229  'uid' => 'childUid',
230  'field' => 'childField',
231  ],
232  ],
233  [
234  'form' => 'data[parentTable][parentUid][parentField]',
235  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
236  ],
237  ],
238  'flexform 3-level table-uid structure' => [
239  'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField-childTable-childUid',
240  [
241  'stable' => [
242  [
243  'table' => 'grandParentTable',
244  'uid' => 'grandParentUid',
245  'field' => 'grandParentField',
246  'flexform' => [
247  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
248  ],
249  'config' => [],
250  ],
251  [
252  'table' => 'parentTable',
253  'uid' => 'parentUid',
254  'field' => 'parentField',
255  'config' => [],
256  ],
257  ],
258  'unstable' => [
259  'table' => 'childTable',
260  'uid' => 'childUid',
261  ],
262  ],
263  [
264  'form' => 'data[parentTable][parentUid][parentField]',
265  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField',
266  ],
267  ],
268  ];
269  }
270 
275  public function ‪initializeByParsingDomObjectIdStringParsesStructureString($string, array $expectedInlineStructure, array $_)
276  {
278  $subject = $this->getAccessibleMock(InlineStackProcessor::class, ['dummy']);
279  $subject->initializeByParsingDomObjectIdString($string);
280  $structure = $subject->_get('inlineStructure');
281  $this->assertEquals($expectedInlineStructure, $structure);
282  }
283 
288  public function ‪getCurrentStructureFormPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
289  {
291  $subject = new ‪InlineStackProcessor;
292  $subject->‪initializeByParsingDomObjectIdString($string);
293  $this->assertEquals($expectedFormName['form'], $subject->getCurrentStructureFormPrefix());
294  }
295 
300  public function ‪getCurrentStructureDomObjectIdPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
301  {
303  $subject = new ‪InlineStackProcessor;
304  $subject->‪initializeByParsingDomObjectIdString($string);
305  $this->assertEquals($expectedFormName['object'], $subject->getCurrentStructureDomObjectIdPrefix('pageId'));
306  }
307 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\getCurrentStructureDomObjectIdPrefixReturnsExpectedStringAfterInitializationByStructureString
‪getCurrentStructureDomObjectIdPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
Definition: InlineStackProcessorTest.php:299
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\setUp
‪setUp()
Definition: InlineStackProcessorTest.php:37
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\structureStringIsParsedDataProvider
‪array structureStringIsParsedDataProvider()
Definition: InlineStackProcessorTest.php:51
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: InlineStackProcessorTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\getCurrentStructureFormPrefixReturnsExpectedStringAfterInitializationByStructureString
‪getCurrentStructureFormPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
Definition: InlineStackProcessorTest.php:287
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest
Definition: InlineStackProcessorTest.php:29
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\initializeByParsingDomObjectIdStringParsesStructureString
‪initializeByParsingDomObjectIdStringParsesStructureString($string, array $expectedInlineStructure, array $_)
Definition: InlineStackProcessorTest.php:274
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Backend\Form\InlineStackProcessor
Definition: InlineStackProcessor.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Tests\Unit\Form
‪TYPO3\CMS\Backend\Form\InlineStackProcessor\initializeByParsingDomObjectIdString
‪initializeByParsingDomObjectIdString($domObjectId)
Definition: InlineStackProcessor.php:56