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