TYPO3 CMS  TYPO3_8-7
InlineOverrrideChildTcaTest.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 
18 
22 class InlineOverrrideChildTcaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
27  protected $subject;
28 
29  protected function setUp()
30  {
31  $this->subject = new InlineOverrideChildTca();
32  }
33 
38  {
39  $input = [
40  'inlineParentConfig' => [
41  'overrideChildTca' => [
42  'types' => [
43  'aType' => [
44  'showitem' => 'keepMe',
45  ],
46  ],
47  ],
48  ],
49  'processedTca' => [
50  'types' => [
51  'aType' => [
52  'showitem' => 'keepMe, aField',
53  ],
54  'bType' => [
55  'showitem' => 'keepMe, aField',
56  ],
57  ],
58  ],
59  ];
60 
61  $expected = $input;
62  $expected['processedTca']['types']['aType']['showitem'] = 'keepMe';
63 
64  $this->assertSame($expected, $this->subject->addData($input));
65  }
66 
71  {
72  $input = [
73  'inlineParentConfig' => [
74  'overrideChildTca' => [
75  'types' => [
76  'aType' => [
77  'showitem' => 'keepMe',
78  ],
79  'cType' => [
80  'showitem' => 'keepMe',
81  ],
82  ],
83  ],
84  ],
85  'processedTca' => [
86  'types' => [
87  'aType' => [
88  'showitem' => 'keepMe, aField',
89  ],
90  'bType' => [
91  'showitem' => 'keepMe, aField',
92  ],
93  ],
94  ],
95  ];
96 
97  $expected = $input;
98  $expected['processedTca']['types']['aType']['showitem'] = 'keepMe';
99  $expected['processedTca']['types']['cType']['showitem'] = 'keepMe';
100 
101  $this->assertSame($expected, $this->subject->addData($input));
102  }
103 
108  {
109  $input = [
110  'inlineParentConfig' => [
111  'foreign_selector' => 'uid_local',
112  'overrideChildTca' => [
113  'columns' => [
114  'uid_local' => [
115  'label' => 'aDifferentLabel',
116  'config' => [
117  'aGivenSetting' => 'overrideValue',
118  'aNewSetting' => 'anotherNewValue',
119  'appearance' => [
120  'elementBrowserType' => 'file',
121  'elementBrowserAllowed' => 'jpg,png'
122  ],
123  ],
124  ],
125  ],
126  ],
127  ],
128  'processedTca' => [
129  'columns' => [
130  'uid_local' => [
131  'label' => 'aLabel',
132  'config' => [
133  'aGivenSetting' => 'aValue',
134  'doNotChangeMe' => 'doNotChangeMe',
135  'appearance' => [
136  'elementBrowserType' => 'db',
137  ],
138  ],
139  ]
140  ],
141  ],
142  ];
143 
144  $expected = $input;
145  $expected['processedTca']['columns']['uid_local'] = [
146  'label' => 'aDifferentLabel',
147  'config' => [
148  'aGivenSetting' => 'overrideValue',
149  'doNotChangeMe' => 'doNotChangeMe',
150  'appearance' => [
151  'elementBrowserType' => 'file',
152  'elementBrowserAllowed' => 'jpg,png',
153  ],
154  'aNewSetting' => 'anotherNewValue',
155  ],
156  ];
157 
158  $this->assertSame($expected, $this->subject->addData($input));
159  }
160 
165  {
166  $input = [
167  'inlineParentConfig' => [
168  'overrideChildTca' => [
169  'columns' => [
170  'aType' => [
171  'config' => [
172  'default' => '42',
173  ],
174  ],
175  ],
176  ],
177  ],
178  'processedTca' => [
179  'columns' => [
180  'aType' => [
181  'config' => [],
182  ],
183  ],
184  ],
185  ];
186 
187  $expected = $input;
188  $expected['processedTca']['columns']['aType']['config']['default'] = '42';
189 
190  $this->assertSame($expected, $this->subject->addData($input));
191  }
192 
197  {
198  $input = [
199  'inlineParentConfig' => [
200  'overrideChildTca' => [
201  'columns' => [
202  'pid' => [
203  'config' => [
204  'default' => '42',
205  ],
206  ],
207  ],
208  ],
209  ],
210  'processedTca' => [
211  'columns' => [
212  'aType' => [
213  'config' => [],
214  ],
215  ],
216  ],
217  ];
218 
219  $this->expectException(\RuntimeException::class);
220  $this->expectExceptionCode(1490371322);
221  $this->subject->addData($input);
222  }
223 }