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