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