‪TYPO3CMS  10.4
InlineOverrideChildTcaTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪InlineOverrideChildTcaTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->subject = new ‪InlineOverrideChildTca();
35  }
36 
41  {
42  $input = [
43  'inlineParentConfig' => [
44  'overrideChildTca' => [
45  'types' => [
46  'aType' => [
47  'showitem' => 'keepMe',
48  ],
49  ],
50  ],
51  ],
52  'processedTca' => [
53  'types' => [
54  'aType' => [
55  'showitem' => 'keepMe, aField',
56  ],
57  'bType' => [
58  'showitem' => 'keepMe, aField',
59  ],
60  ],
61  ],
62  ];
63 
64  $expected = $input;
65  $expected['processedTca']['types']['aType']['showitem'] = 'keepMe';
66 
67  self::assertSame($expected, $this->subject->addData($input));
68  }
69 
74  {
75  $input = [
76  'inlineParentConfig' => [
77  'overrideChildTca' => [
78  'types' => [
79  'aType' => [
80  'showitem' => 'keepMe',
81  ],
82  'cType' => [
83  'showitem' => 'keepMe',
84  ],
85  ],
86  ],
87  ],
88  'processedTca' => [
89  'types' => [
90  'aType' => [
91  'showitem' => 'keepMe, aField',
92  ],
93  'bType' => [
94  'showitem' => 'keepMe, aField',
95  ],
96  ],
97  ],
98  ];
99 
100  $expected = $input;
101  $expected['processedTca']['types']['aType']['showitem'] = 'keepMe';
102  $expected['processedTca']['types']['cType']['showitem'] = 'keepMe';
103 
104  self::assertSame($expected, $this->subject->addData($input));
105  }
106 
111  {
112  $input = [
113  'inlineParentConfig' => [
114  'foreign_selector' => 'uid_local',
115  'overrideChildTca' => [
116  'columns' => [
117  'uid_local' => [
118  'label' => 'aDifferentLabel',
119  'config' => [
120  'aGivenSetting' => 'overrideValue',
121  'aNewSetting' => 'anotherNewValue',
122  'appearance' => [
123  'elementBrowserType' => 'file',
124  'elementBrowserAllowed' => 'jpg,png'
125  ],
126  ],
127  ],
128  ],
129  ],
130  ],
131  'processedTca' => [
132  'columns' => [
133  'uid_local' => [
134  'label' => 'aLabel',
135  'config' => [
136  'aGivenSetting' => 'aValue',
137  'doNotChangeMe' => 'doNotChangeMe',
138  'appearance' => [
139  'elementBrowserType' => 'db',
140  ],
141  ],
142  ]
143  ],
144  ],
145  ];
146 
147  $expected = $input;
148  $expected['processedTca']['columns']['uid_local'] = [
149  'label' => 'aDifferentLabel',
150  'config' => [
151  'aGivenSetting' => 'overrideValue',
152  'doNotChangeMe' => 'doNotChangeMe',
153  'appearance' => [
154  'elementBrowserType' => 'file',
155  'elementBrowserAllowed' => 'jpg,png',
156  ],
157  'aNewSetting' => 'anotherNewValue',
158  ],
159  ];
160 
161  self::assertSame($expected, $this->subject->addData($input));
162  }
163 
168  {
169  $input = [
170  'inlineParentConfig' => [
171  'overrideChildTca' => [
172  'columns' => [
173  'aType' => [
174  'config' => [
175  'default' => '42',
176  ],
177  ],
178  ],
179  ],
180  ],
181  'processedTca' => [
182  'columns' => [
183  'aType' => [
184  'config' => [],
185  ],
186  ],
187  ],
188  ];
189 
190  $expected = $input;
191  $expected['processedTca']['columns']['aType']['config']['default'] = '42';
192 
193  self::assertSame($expected, $this->subject->addData($input));
194  }
195 
200  {
201  $input = [
202  'inlineParentConfig' => [
203  'overrideChildTca' => [
204  'columns' => [
205  'pid' => [
206  'config' => [
207  'default' => '42',
208  ],
209  ],
210  ],
211  ],
212  ],
213  'processedTca' => [
214  'columns' => [
215  'aType' => [
216  'config' => [],
217  ],
218  ],
219  ],
220  ];
221 
222  $this->expectException(\RuntimeException::class);
223  $this->expectExceptionCode(1490371322);
224  $this->subject->addData($input);
225  }
226 }
‪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:25
‪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