‪TYPO3CMS  11.5
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 Prophecy\PhpUnit\ProphecyTrait;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
26 {
27  use ProphecyTrait;
28 
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->subject = new ‪TcaColumnsProcessFieldDescriptions();
35  }
36 
41  {
42  $input = [
43  'tableName' => 'aTable',
44  'processedTca' => [
45  'columns' => [
46  'aField' => [
47  'description' => 'foo',
48  ],
49  ],
50  ],
51  ];
52  $languageServiceProphecy = $this->prophesize(LanguageService::class);
53  $languageServiceProphecy->sL('foo')->shouldBeCalled()->willReturnArgument(0);
54  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
55 
56  $expected = $input;
57  self::assertSame($expected, $this->subject->addData($input));
58  }
59 
63  public function ‪addDataAddsDescriptionToExistingField(): void
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  $languageServiceProphecy = $this->prophesize(LanguageService::class);
83  $languageServiceProphecy->sL('aNewDescription')->shouldBeCalled()->willReturnArgument(0);
84  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
85 
86  $expected = $input;
87  $expected['processedTca']['columns']['aField']['description'] = 'aNewDescription';
88  self::assertSame($expected, $this->subject->addData($input));
89  }
90 
94  public function ‪addDataSetsDescriptionFromPageTsConfig(): void
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  $languageServiceProphecy = $this->prophesize(LanguageService::class);
116  $languageServiceProphecy->sL('aDescriptionOverride')->shouldBeCalled()->willReturnArgument(0);
117  ‪$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
118 
119  $expected = $input;
120  $expected['processedTca']['columns']['aField']['description'] = 'aDescriptionOverride';
121  self::assertSame($expected, $this->subject->addData($input));
122  }
123 
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  $languageServiceProphecy = $this->prophesize(LanguageService::class);
151  $languageServiceProphecy->sL('aDescriptionOverride')->shouldBeCalled()->willReturnArgument(0);
152  $languageService = $languageServiceProphecy->reveal();
153  $languageService->lang = 'fr';
154  ‪$GLOBALS['LANG'] = $languageService;
155 
156  $expected = $input;
157  $expected['processedTca']['columns']['aField']['description'] = 'aDescriptionOverride';
158  self::assertSame($expected, $this->subject->addData($input));
159  }
160 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataSetsDescriptionFromPageTsConfigForSpecificLanguage
‪addDataSetsDescriptionFromPageTsConfigForSpecificLanguage()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:126
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest
Definition: TcaColumnsProcessFieldDescriptionsTest.php:26
‪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:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataAddsDescriptionToExistingField
‪addDataAddsDescriptionToExistingField()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:62
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\setUp
‪setUp()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaColumnsProcessFieldDescriptionsTest\addDataSetsDescriptionFromPageTsConfig
‪addDataSetsDescriptionFromPageTsConfig()
Definition: TcaColumnsProcessFieldDescriptionsTest.php:93
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18