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