‪TYPO3CMS  10.4
TcaColumnsProcessFieldLabelsTest.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 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪TcaColumnsProcessFieldLabelsTest extends UnitTestCase
26 {
31  {
32  $input = [
33  'tableName' => 'aTable',
34  'processedTca' => [
35  'columns' => [
36  'aField' => [
37  'label' => 'foo',
38  ],
39  ],
40  ],
41  'recordTypeValue' => 'aType',
42  ];
43  $languageServiceProphecy = $this->prophesize(LanguageService::class);
44  $languageServiceProphecy->sL('foo')->shouldBeCalled()->willReturnArgument(0);
45  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
46 
47  $expected = $input;
48  self::assertSame($expected, (new ‪TcaColumnsProcessFieldLabels())->addData($input));
49  }
50 
55  {
56  $input = [
57  'tableName' => 'aTable',
58  'processedTca' => [
59  'columns' => [
60  'aField' => [
61  'label' => 'origLabel',
62  ],
63  ],
64  'types' => [
65  'aType' => [
66  'showitem' => 'aField;aLabelOverride',
67  ],
68  ],
69  ],
70  'recordTypeValue' => 'aType',
71  ];
72  $languageServiceProphecy = $this->prophesize(LanguageService::class);
73  $languageServiceProphecy->sL('aLabelOverride')->shouldBeCalled()->willReturnArgument(0);
74  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
75 
76  $expected = $input;
77  $expected['processedTca']['columns']['aField']['label'] = 'aLabelOverride';
78  self::assertSame($expected, (new ‪TcaColumnsProcessFieldLabels())->addData($input));
79  }
80 
85  {
86  $input = [
87  'tableName' => 'aTable',
88  'processedTca' => [
89  'columns' => [
90  'aField' => [
91  'label' => 'origLabel',
92  ],
93  ],
94  'types' => [
95  'aType' => [
96  'showitem' => '--palette--;;aPalette',
97  ],
98  ],
99  'palettes' => [
100  'aPalette' => [
101  'showitem' => 'aField;aLabelOverride',
102  ],
103  ],
104  ],
105  'recordTypeValue' => 'aType',
106  ];
107  $languageServiceProphecy = $this->prophesize(LanguageService::class);
108  $languageServiceProphecy->sL('aLabelOverride')->shouldBeCalled()->willReturnArgument(0);
109  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
110 
111  $expected = $input;
112  $expected['processedTca']['columns']['aField']['label'] = 'aLabelOverride';
113  self::assertSame($expected, (new ‪TcaColumnsProcessFieldLabels())->addData($input));
114  }
115 
120  {
121  $input = [
122  'tableName' => 'aTable',
123  'processedTca' => [
124  'columns' => [
125  'aField' => [
126  'label' => 'origLabel',
127  ],
128  ],
129  ],
130  'pageTsConfig' => [
131  'TCEFORM.' => [
132  'aTable.' => [
133  'aField.' => [
134  'label' => 'aLabelOverride',
135  ],
136  ],
137  ],
138  ],
139  'recordTypeValue' => 'aType',
140  ];
141  $languageServiceProphecy = $this->prophesize(LanguageService::class);
142  $languageServiceProphecy->sL('aLabelOverride')->shouldBeCalled()->willReturnArgument(0);
143  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
144 
145  $expected = $input;
146  $expected['processedTca']['columns']['aField']['label'] = 'aLabelOverride';
147  self::assertSame($expected, (new ‪TcaColumnsProcessFieldLabels())->addData($input));
148  }
149 
154  {
155  $input = [
156  'tableName' => 'aTable',
157  'processedTca' => [
158  'columns' => [
159  'aField' => [
160  'label' => 'origLabel',
161  ],
162  ],
163  ],
164  'pageTsConfig' => [
165  'TCEFORM.' => [
166  'aTable.' => [
167  'aField.' => [
168  'label.' => [
169  'fr' => 'aLabelOverride',
170  ],
171  ],
172  ],
173  ],
174  ],
175  'recordTypeValue' => 'aType',
176  ];
177  $languageServiceProphecy = $this->prophesize(LanguageService::class);
178  $languageServiceProphecy->lang = 'fr';
179  $languageServiceProphecy->sL('aLabelOverride')->shouldBeCalled()->willReturnArgument(0);
180  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
181 
182  $expected = $input;
183  $expected['processedTca']['columns']['aField']['label'] = 'aLabelOverride';
184  self::assertSame($expected, (new ‪TcaColumnsProcessFieldLabels())->addData($input));
185  }
186 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldLabelsTest
Definition: TcaColumnsProcessFieldLabelsTest.php:26
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldLabels
Definition: TcaColumnsProcessFieldLabels.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldLabelsTest\addDataSetsLabelFromShowitem
‪addDataSetsLabelFromShowitem()
Definition: TcaColumnsProcessFieldLabelsTest.php:54
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldLabelsTest\addDataSetsLabelFromPageTsConfigForSpecificLanguage
‪addDataSetsLabelFromPageTsConfigForSpecificLanguage()
Definition: TcaColumnsProcessFieldLabelsTest.php:153
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldLabelsTest\addDataSetsLabelFromPalettesShowitem
‪addDataSetsLabelFromPalettesShowitem()
Definition: TcaColumnsProcessFieldLabelsTest.php:84
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldLabelsTest\addDataSetsLabelFromPageTsConfig
‪addDataSetsLabelFromPageTsConfig()
Definition: TcaColumnsProcessFieldLabelsTest.php:119
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldLabelsTest\addDataKeepsLabelAsIsIfNoOverrideIsGiven
‪addDataKeepsLabelAsIsIfNoOverrideIsGiven()
Definition: TcaColumnsProcessFieldLabelsTest.php:30
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18