‪TYPO3CMS  9.5
TcaColumnsOverridesTest.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 ‪TcaColumnsOverridesTest extends UnitTestCase
24 {
28  protected ‪$subject;
29 
30  protected function ‪setUp()
31  {
32  $this->subject = new ‪TcaColumnsOverrides();
33  }
34 
39  {
40  $input = [
41  'command' => 'new',
42  'tableName' => 'aTable',
43  'recordTypeValue' => 'foo',
44  'processedTca' => [
45  'columns' => [],
46  'types' => [
47  'foo' => [
48  'showitem' => [],
49  'columnsOverrides' => [],
50  ],
51  ],
52  ],
53  ];
54 
55  $expected = $input;
56  unset($expected['processedTca']['types']['foo']['columnsOverrides']);
57 
58  $this->assertEquals($expected, $this->subject->addData($input));
59  }
60 
65  {
66  $input = [
67  'command' => 'new',
68  'tableName' => 'aTable',
69  'recordTypeValue' => 'foo',
70  'processedTca' => [
71  'columns' => [
72  'aField' => [
73  'aConfig' => 'aValue',
74  'anotherConfig' => 'anotherValue',
75  ],
76  ],
77  'types' => [
78  'foo' => [
79  'showitem' => [],
80  'columnsOverrides' => [
81  'aField' => [
82  'aConfig' => 'aDifferentValue',
83  ],
84  ],
85  ],
86  ],
87  ],
88  ];
89 
90  $expected = $input;
91  $expected['processedTca']['columns']['aField']['aConfig'] = 'aDifferentValue';
92  unset($expected['processedTca']['types']['foo']['columnsOverrides']);
93 
94  $this->assertEquals($expected, $this->subject->addData($input));
95  }
96 
101  {
102  $input = [
103  'command' => 'new',
104  'tableName' => 'aTable',
105  'vanillaUid' => 12,
106  'databaseRow' => [
107  'uid' => 42,
108  ],
109  'recordTypeValue' => 'foo',
110  'processedTca' => [
111  'columns' => [
112  'aField' => [
113  'aConfig' => 'aValue'
114  ],
115  ],
116  'types' => [
117  'foo' => [
118  'showitem' => [],
119  'columnsOverrides' => [
120  'aField' => [
121  'config' => [
122  'default' => 'aDefault'
123  ]
124  ],
125  ],
126  ],
127  ],
128  ],
129  ];
130 
131  $expected = $input;
132  $expected['databaseRow']['aField'] = 'aDefault';
133  $expected['processedTca']['columns']['aField']['config']['default'] = 'aDefault';
134  unset($expected['processedTca']['types']['foo']['columnsOverrides']);
135 
136  self::assertEquals($expected, $this->subject->addData($input));
137  }
138 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\setUp
‪setUp()
Definition: TcaColumnsOverridesTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\$subject
‪TcaColumnsOverrides $subject
Definition: TcaColumnsOverridesTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest
Definition: TcaColumnsOverridesTest.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\addDataRemovesGivenColumnsOverrides
‪addDataRemovesGivenColumnsOverrides()
Definition: TcaColumnsOverridesTest.php:37
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\addDataMergesColumnsOverridesDefaultValueIntoDatabaseRow
‪addDataMergesColumnsOverridesDefaultValueIntoDatabaseRow()
Definition: TcaColumnsOverridesTest.php:99
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsOverrides
Definition: TcaColumnsOverrides.php:23
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsOverridesTest\addDataMergesColumnsOverridesIntoColumns
‪addDataMergesColumnsOverridesIntoColumns()
Definition: TcaColumnsOverridesTest.php:63
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:3