‪TYPO3CMS  ‪main
TcaColumnsProcessFieldDescriptionsTest.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;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
28 final class ‪TcaColumnsProcessFieldDescriptionsTest extends UnitTestCase
29 {
31 
32  protected function ‪setUp(): void
33  {
34  parent::setUp();
35  $this->subject = new ‪TcaColumnsProcessFieldDescriptions();
36  }
37 
38  #[Test]
40  {
41  $input = [
42  'tableName' => 'aTable',
43  'processedTca' => [
44  'columns' => [
45  'aField' => [
46  'description' => 'foo',
47  ],
48  ],
49  ],
50  ];
51 
52  ‪$GLOBALS['LANG'] = new ‪LanguageService(
53  new ‪Locales(),
54  $this->createMock(LocalizationFactory::class),
55  $this->createMock(FrontendInterface::class)
56  );
57 
58  $expected = $input;
59  self::assertSame($expected, $this->subject->addData($input));
60  }
61 
62  #[Test]
64  {
65  $input = [
66  'tableName' => 'aTable',
67  'processedTca' => [
68  'columns' => [
69  'aField' => [],
70  ],
71  ],
72  'pageTsConfig' => [
73  'TCEFORM.' => [
74  'aTable.' => [
75  'aField.' => [
76  'description' => 'aNewDescription',
77  ],
78  ],
79  ],
80  ],
81  ];
82  ‪$GLOBALS['LANG'] = new ‪LanguageService(
83  new ‪Locales(),
84  $this->createMock(LocalizationFactory::class),
85  $this->createMock(FrontendInterface::class)
86  );
87 
88  $expected = $input;
89  $expected['processedTca']['columns']['aField']['description'] = 'aNewDescription';
90  self::assertSame($expected, $this->subject->addData($input));
91  }
92 
93  #[Test]
95  {
96  $input = [
97  'tableName' => 'aTable',
98  'processedTca' => [
99  'columns' => [
100  'aField' => [
101  'description' => 'origDescription',
102  ],
103  ],
104  ],
105  'pageTsConfig' => [
106  'TCEFORM.' => [
107  'aTable.' => [
108  'aField.' => [
109  'description' => 'aDescriptionOverride',
110  ],
111  ],
112  ],
113  ],
114  ];
115  ‪$GLOBALS['LANG'] = new ‪LanguageService(
116  new ‪Locales(),
117  $this->createMock(LocalizationFactory::class),
118  $this->createMock(FrontendInterface::class)
119  );
120 
121  $expected = $input;
122  $expected['processedTca']['columns']['aField']['description'] = 'aDescriptionOverride';
123  self::assertSame($expected, $this->subject->addData($input));
124  }
125 
126  #[Test]
128  {
129  $input = [
130  'tableName' => 'aTable',
131  'processedTca' => [
132  'columns' => [
133  'aField' => [
134  'description' => 'origDescription',
135  ],
136  ],
137  ],
138  'pageTsConfig' => [
139  'TCEFORM.' => [
140  'aTable.' => [
141  'aField.' => [
142  'description.' => [
143  'fr' => 'aDescriptionOverride',
144  ],
145  ],
146  ],
147  ],
148  ],
149  ];
150  ‪$GLOBALS['LANG'] = new ‪LanguageService(
151  new ‪Locales(),
152  $this->createMock(LocalizationFactory::class),
153  $this->createMock(FrontendInterface::class)
154  );
155  ‪$GLOBALS['LANG']->init('fr');
156 
157  $expected = $input;
158  $expected['processedTca']['columns']['aField']['description'] = 'aDescriptionOverride';
159  self::assertSame($expected, $this->subject->addData($input));
160  }
161 }
‪TYPO3\CMS\Core\Localization\LocalizationFactory
Definition: LocalizationFactory.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataSetsDescriptionFromPageTsConfigForSpecificLanguage
‪addDataSetsDescriptionFromPageTsConfigForSpecificLanguage()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:127
‪TYPO3\CMS\Core\Localization\Locales
Definition: Locales.php:36
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest
Definition: TcaColumnsProcessFieldDescriptionsTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataKeepsDescriptionAsIsIfNoOverrideIsGiven
‪addDataKeepsDescriptionAsIsIfNoOverrideIsGiven()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:39
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions
Definition: TcaColumnsProcessFieldDescriptions.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\$subject
‪TcaColumnsProcessFieldDescriptions $subject
Definition: TcaColumnsProcessFieldDescriptionsTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataAddsDescriptionToExistingField
‪addDataAddsDescriptionToExistingField()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:63
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\setUp
‪setUp()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:32
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataSetsDescriptionFromPageTsConfig
‪addDataSetsDescriptionFromPageTsConfig()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:94
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18