TYPO3 CMS  TYPO3_7-6
TcaFlexFetchTest.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 
25 
30 {
34  protected $subject;
35 
40 
44  protected $singletonInstances = [];
45 
46  protected function setUp()
47  {
48  $this->singletonInstances = GeneralUtility::getSingletonInstances();
49 
50  // Suppress cache foo in xml helpers of GeneralUtility
52  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
53  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
54  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
55  $cacheManagerProphecy->getCache(Argument::cetera())->willReturn($cacheFrontendProphecy->reveal());
56 
57  $this->subject = new TcaFlexFetch();
58  }
59 
60  protected function tearDown()
61  {
63  GeneralUtility::resetSingletonInstances($this->singletonInstances);
64  parent::tearDown();
65  }
66 
71  {
72  $input = [
73  'systemLanguageRows' => [],
74  'databaseRow' => [
75  'aField' => [
76  'data' => [],
77  'meta' => [],
78  ],
79  ],
80  'processedTca' => [
81  'columns' => [
82  'aField' => [
83  'config' => [
84  'type' => 'flex',
85  'ds' => [
86  'default' => '
87  <T3DataStructure>
88  <ROOT>
89  <type>array</type>
90  <el>
91  <aFlexField>
92  <TCEforms>
93  <label>aFlexFieldLabel</label>
94  <config>
95  <type>input</type>
96  </config>
97  </TCEforms>
98  </aFlexField>
99  </el>
100  </ROOT>
101  </T3DataStructure>
102  ',
103  ],
104  ],
105  ],
106  ],
107  ],
108  ];
109 
110  $expected = $input;
111  $expected['processedTca']['columns']['aField']['config']['ds'] = [
112  'ROOT' => [
113  'type' => 'array',
114  'el' => [
115  'aFlexField' => [
116  'TCEforms' => [
117  'label' => 'aFlexFieldLabel',
118  'config' => [
119  'type' => 'input',
120  ],
121  ],
122  ],
123  ],
124  ],
125  'meta' => [],
126  ];
127 
128  $this->assertEquals($expected, $this->subject->addData($input));
129  }
130 
135  {
136  $input = [
137  'systemLanguageRows' => [],
138  'databaseRow' => [
139  'aField' => [
140  'data' => [],
141  'meta' => [],
142  ],
143  ],
144  'processedTca' => [
145  'columns' => [
146  'aField' => [
147  'config' => [
148  'type' => 'flex',
149  'ds' => [
150  'default' => '
151  <T3DataStructure>
152  <sheets>
153  <sDEF>
154  <ROOT>
155  <TCEforms>
156  <sheetTitle>aTitle</sheetTitle>
157  </TCEforms>
158  <type>array</type>
159  <el>
160  <aFlexField>
161  <TCEforms>
162  <label>aFlexFieldLabel</label>
163  <config>
164  <type>input</type>
165  </config>
166  </TCEforms>
167  </aFlexField>
168  </el>
169  </ROOT>
170  </sDEF>
171  </sheets>
172  </T3DataStructure>
173  ',
174  ],
175  ],
176  ],
177  ],
178  ],
179  ];
180 
181  $expected = $input;
182  $expected['processedTca']['columns']['aField']['config']['ds'] = [
183  'sheets' => [
184  'sDEF' => [
185  'ROOT' => [
186  'type' => 'array',
187  'el' => [
188  'aFlexField' => [
189  'TCEforms' => [
190  'label' => 'aFlexFieldLabel',
191  'config' => [
192  'type' => 'input',
193  ],
194  ],
195  ],
196  ],
197  'TCEforms' => [
198  'sheetTitle' => 'aTitle',
199  ],
200  ],
201  ],
202  ],
203  'meta' => [],
204  ];
205 
206  $this->assertEquals($expected, $this->subject->addData($input));
207  }
208 
213  {
214  $input = [
215  'systemLanguageRows' => [],
216  'databaseRow' => [],
217  'processedTca' => [
218  'columns' => [
219  'aField' => [
220  'config' => [
221  'type' => 'flex',
222  'ds' => ''
223  ],
224  ],
225  ],
226  ],
227  ];
228 
229  $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1440506893);
230 
231  $this->subject->addData($input);
232  }
233 
238  {
239  $input = [
240  'databaseRow' => [],
241  'systemLanguageRows' => [],
242  'processedTca' => [
243  'columns' => [
244  'aField' => [
245  'config' => [
246  'type' => 'flex',
247  'ds' => [
248  'default' => '
249  <T3DataStructure>
250  <ROOT></ROOT>
251  </T3DataStructure>
252  ',
253  ],
254  ],
255  ],
256  ],
257  ],
258  ];
259 
260  $expected = $input;
261  $expected['processedTca']['columns']['aField']['config']['ds'] = [
262  'ROOT' => '',
263  'meta' => [],
264  ];
265  $expected['databaseRow']['aField'] = [
266  'data' => [],
267  'meta' => []
268  ];
269 
270  $this->assertEquals($expected, $this->subject->addData($input));
271  }
272 }
static setSingletonInstance($className, SingletonInterface $instance)
static resetSingletonInstances(array $newSingletonInstances)