‪TYPO3CMS  10.4
InlineStackProcessorTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
20 use Prophecy\Argument;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪InlineStackProcessorTest extends UnitTestCase
31 {
35  protected ‪$resetSingletonInstances = true;
36 
40  public function ‪setUp(): void
41  {
42  parent::setUp();
43  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
44  $cacheProphecy = $this->prophesize(FrontendInterface::class);
45  $cacheManagerProphecy->getCache('runtime')->willReturn($cacheProphecy->reveal());
46  $cacheProphecy->get(Argument::cetera())->willReturn(false);
47  $cacheProphecy->set(Argument::cetera())->willReturn(false);
48  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
49  }
50 
55  {
56  return [
57  'simple 1-level table structure' => [
58  'data-pageId-childTable',
59  [
60  'unstable' => [
61  'table' => 'childTable',
62  ],
63  ],
64  [
65  'form' => '',
66  'object' => '',
67  ]
68  ],
69  'simple 1-level table-uid structure' => [
70  'data-pageId-childTable-childUid',
71  [
72  'unstable' => [
73  'table' => 'childTable',
74  'uid' => 'childUid',
75  ],
76  ],
77  [
78  'form' => '',
79  'object' => '',
80  ]
81  ],
82  'simple 1-level table-uid-field structure' => [
83  'data-pageId-childTable-childUid-childField',
84  [
85  'unstable' => [
86  'table' => 'childTable',
87  'uid' => 'childUid',
88  'field' => 'childField',
89  ],
90  ],
91  [
92  'form' => '',
93  'object' => '',
94  ],
95  ],
96  'simple 2-level table structure' => [
97  'data-pageId-parentTable-parentUid-parentField-childTable',
98  [
99  'stable' => [
100  [
101  'table' => 'parentTable',
102  'uid' => 'parentUid',
103  'field' => 'parentField',
104  'config' => [],
105  ],
106  ],
107  'unstable' => [
108  'table' => 'childTable',
109  ],
110  ],
111  [
112  'form' => 'data[parentTable][parentUid][parentField]',
113  'object' => 'data-pageId-parentTable-parentUid-parentField',
114  ],
115  ],
116  'simple 2-level table-uid structure' => [
117  'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
118  [
119  'stable' => [
120  [
121  'table' => 'parentTable',
122  'uid' => 'parentUid',
123  'field' => 'parentField',
124  'config' => [],
125  ],
126  ],
127  'unstable' => [
128  'table' => 'childTable',
129  'uid' => 'childUid',
130  ],
131  ],
132  [
133  'form' => 'data[parentTable][parentUid][parentField]',
134  'object' => 'data-pageId-parentTable-parentUid-parentField',
135  ],
136  ],
137  'simple 2-level table-uid-field structure' => [
138  'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
139  [
140  'stable' => [
141  [
142  'table' => 'parentTable',
143  'uid' => 'parentUid',
144  'field' => 'parentField',
145  'config' => [],
146  ],
147  ],
148  'unstable' => [
149  'table' => 'childTable',
150  'uid' => 'childUid',
151  'field' => 'childField',
152  ],
153  ],
154  [
155  'form' => 'data[parentTable][parentUid][parentField]',
156  'object' => 'data-pageId-parentTable-parentUid-parentField',
157  ],
158  ],
159  'simple 3-level table structure' => [
160  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
161  [
162  'stable' => [
163  [
164  'table' => 'grandParentTable',
165  'uid' => 'grandParentUid',
166  'field' => 'grandParentField',
167  'config' => [],
168  ],
169  [
170  'table' => 'parentTable',
171  'uid' => 'parentUid',
172  'field' => 'parentField',
173  'config' => [],
174  ],
175  ],
176  'unstable' => [
177  'table' => 'childTable',
178  ],
179  ],
180  [
181  'form' => 'data[parentTable][parentUid][parentField]',
182  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
183  ],
184  ],
185  'simple 3-level table-uid structure' => [
186  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
187  [
188  'stable' => [
189  [
190  'table' => 'grandParentTable',
191  'uid' => 'grandParentUid',
192  'field' => 'grandParentField',
193  'config' => [],
194  ],
195  [
196  'table' => 'parentTable',
197  'uid' => 'parentUid',
198  'field' => 'parentField',
199  'config' => [],
200  ],
201  ],
202  'unstable' => [
203  'table' => 'childTable',
204  'uid' => 'childUid',
205  ],
206  ],
207  [
208  'form' => 'data[parentTable][parentUid][parentField]',
209  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
210  ],
211  ],
212  'simple 3-level table-uid-field structure' => [
213  'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
214  [
215  'stable' => [
216  [
217  'table' => 'grandParentTable',
218  'uid' => 'grandParentUid',
219  'field' => 'grandParentField',
220  'config' => [],
221  ],
222  [
223  'table' => 'parentTable',
224  'uid' => 'parentUid',
225  'field' => 'parentField',
226  'config' => [],
227  ],
228  ],
229  'unstable' => [
230  'table' => 'childTable',
231  'uid' => 'childUid',
232  'field' => 'childField',
233  ],
234  ],
235  [
236  'form' => 'data[parentTable][parentUid][parentField]',
237  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
238  ],
239  ],
240  'flexform 3-level table-uid structure' => [
241  'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField-childTable-childUid',
242  [
243  'stable' => [
244  [
245  'table' => 'grandParentTable',
246  'uid' => 'grandParentUid',
247  'field' => 'grandParentField',
248  'flexform' => [
249  'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF',
250  ],
251  'config' => [],
252  ],
253  [
254  'table' => 'parentTable',
255  'uid' => 'parentUid',
256  'field' => 'parentField',
257  'config' => [],
258  ],
259  ],
260  'unstable' => [
261  'table' => 'childTable',
262  'uid' => 'childUid',
263  ],
264  ],
265  [
266  'form' => 'data[parentTable][parentUid][parentField]',
267  'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField',
268  ],
269  ],
270  ];
271  }
272 
277  public function ‪initializeByParsingDomObjectIdStringParsesStructureString($string, array $expectedInlineStructure, array $_)
278  {
280  $subject = $this->getAccessibleMock(InlineStackProcessor::class, ['dummy']);
281  $subject->initializeByParsingDomObjectIdString($string);
282  $structure = $subject->_get('inlineStructure');
283  self::assertEquals($expectedInlineStructure, $structure);
284  }
285 
290  public function ‪getCurrentStructureFormPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
291  {
293  $subject = new ‪InlineStackProcessor();
294  $subject->initializeByParsingDomObjectIdString($string);
295  self::assertEquals($expectedFormName['form'], $subject->getCurrentStructureFormPrefix());
296  }
297 
302  public function ‪getCurrentStructureDomObjectIdPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
303  {
305  $subject = new ‪InlineStackProcessor();
306  $subject->initializeByParsingDomObjectIdString($string);
307  self::assertEquals($expectedFormName['object'], $subject->getCurrentStructureDomObjectIdPrefix('pageId'));
308  }
309 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\getCurrentStructureDomObjectIdPrefixReturnsExpectedStringAfterInitializationByStructureString
‪getCurrentStructureDomObjectIdPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
Definition: InlineStackProcessorTest.php:301
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\setUp
‪setUp()
Definition: InlineStackProcessorTest.php:39
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\structureStringIsParsedDataProvider
‪array structureStringIsParsedDataProvider()
Definition: InlineStackProcessorTest.php:53
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: InlineStackProcessorTest.php:34
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\getCurrentStructureFormPrefixReturnsExpectedStringAfterInitializationByStructureString
‪getCurrentStructureFormPrefixReturnsExpectedStringAfterInitializationByStructureString($string, array $_, array $expectedFormName)
Definition: InlineStackProcessorTest.php:289
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest
Definition: InlineStackProcessorTest.php:31
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:35
‪TYPO3\CMS\Backend\Tests\Unit\Form\InlineStackProcessorTest\initializeByParsingDomObjectIdStringParsesStructureString
‪initializeByParsingDomObjectIdStringParsesStructureString($string, array $expectedInlineStructure, array $_)
Definition: InlineStackProcessorTest.php:276
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Backend\Form\InlineStackProcessor
Definition: InlineStackProcessor.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Tests\Unit\Form