‪TYPO3CMS  10.4
GetUniqueTranslationTest.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 
22 
24 {
28  const ‪PAGE_DATAHANDLER = 88;
29 
33  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/';
34 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38  $this->‪importScenarioDataSet('LiveDefaultPages');
39  $this->‪importScenarioDataSet('LiveDefaultElements');
40  $this->backendUser->workspace = 0;
41  }
42 
47  {
48  // Mis-using the "keywords" field in the scenario data-set to check for uniqueness
49  ‪$GLOBALS['TCA']['pages']['columns']['keywords']['l10n_mode'] = 'exclude';
50  ‪$GLOBALS['TCA']['pages']['columns']['keywords']['transOrigPointerField'] = 'l10n_parent';
51  ‪$GLOBALS['TCA']['pages']['columns']['keywords']['languageField'] = 'sys_language_uid';
52  ‪$GLOBALS['TCA']['pages']['columns']['keywords']['config']['eval'] = 'unique';
53  $map = $this->actionService->localizeRecord('pages', self::PAGE_DATAHANDLER, 1);
54  $newPageId = $map['pages'][‪self::PAGE_DATAHANDLER];
55 
56  $originalLanguageRecord = ‪BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
57  $translatedRecord = ‪BackendUtility::getRecord('pages', $newPageId);
58 
59  self::assertEquals('datahandler', $originalLanguageRecord['keywords']);
60  self::assertEquals('datahandler', $translatedRecord['keywords']);
61  }
62 
67  {
68  // Mis-using the "nav_title" field in the scenario data-set to check for uniqueness
69  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['l10n_mode'] = 'exclude';
70  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['transOrigPointerField'] = 'l10n_parent';
71  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['languageField'] = 'sys_language_uid';
72  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['config']['eval'] = 'unique';
73  $map = $this->actionService->localizeRecord('pages', self::PAGE_DATAHANDLER, 1);
74  $newPageId = $map['pages'][‪self::PAGE_DATAHANDLER];
75 
76  $translatedRecord = ‪BackendUtility::getRecord('pages', $newPageId);
77  $this->actionService->modifyRecord('pages', self::PAGE_DATAHANDLER, [
78  'title' => 'DataHandlerTest changed',
79  'nav_title' => 'datahandler'
80  ]);
81  $originalLanguageRecord = ‪BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
82 
83  self::assertEquals('DataHandlerTest changed', $originalLanguageRecord['title']);
84  self::assertEquals('datahandler', $originalLanguageRecord['nav_title']);
85  self::assertEquals('datahandler', $translatedRecord['nav_title']);
86  }
87 
92  {
93  // Mis-using the "nav_title" field in the scenario data-set to check for uniqueness
94  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['l10n_mode'] = 'exclude';
95  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['transOrigPointerField'] = 'l10n_parent';
96  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['languageField'] = 'sys_language_uid';
97  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['config']['eval'] = 'unique';
98  $map = $this->actionService->createNewRecord('pages', -self::PAGE_DATAHANDLER, [
99  'title' => 'New Page',
100  'doktype' => 1
101  ]);
102  $newPageId = $map['pages'][0];
103 
104  $this->actionService->modifyRecord('pages', $newPageId, [
105  'nav_title' => 'datahandler'
106  ]);
107  $originalLanguageRecord = ‪BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
108  $newRecord = ‪BackendUtility::getRecord('pages', $newPageId);
109  self::assertEquals('datahandler', $originalLanguageRecord['nav_title']);
110  self::assertEquals('datahandler0', $newRecord['nav_title']);
111  }
112 
117  {
118  // Mis-using the "nav_title" field in the scenario data-set to check for uniqueness
119  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['l10n_mode'] = 'exclude';
120  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['transOrigPointerField'] = 'l10n_parent';
121  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['languageField'] = 'sys_language_uid';
122  ‪$GLOBALS['TCA']['pages']['columns']['nav_title']['config']['eval'] = 'unique';
123  $map = $this->actionService->createNewRecord('pages', -self::PAGE_DATAHANDLER, [
124  'title' => 'New Page',
125  'doktype' => 1,
126  'nav_title' => 'datahandler',
127  'sys_language_uid' => 1
128  ]);
129  $newPageId = $map['pages'][0];
130 
131  $defaultLanguageRecord = ‪BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
132  $newRecord = ‪BackendUtility::getRecord('pages', $newPageId);
133  self::assertEquals('datahandler', $defaultLanguageRecord['nav_title']);
134  self::assertEquals('datahandler0', $newRecord['nav_title']);
135  }
136 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler
Definition: DefaultValuesTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: GetUniqueTranslationTest.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\valueOfUniqueFieldExcludedInTranslationIsIncrementedInNewTranslatedRecord
‪valueOfUniqueFieldExcludedInTranslationIsIncrementedInNewTranslatedRecord()
Definition: GetUniqueTranslationTest.php:115
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\valueOfUniqueFieldExcludedInTranslationIsIncrementedInNewOriginalRecord
‪valueOfUniqueFieldExcludedInTranslationIsIncrementedInNewOriginalRecord()
Definition: GetUniqueTranslationTest.php:90
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\setUp
‪setUp()
Definition: GetUniqueTranslationTest.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\PAGE_DATAHANDLER
‪const PAGE_DATAHANDLER
Definition: GetUniqueTranslationTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest
Definition: GetUniqueTranslationTest.php:24
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\valueOfUniqueFieldExcludedInTranslationIsUntouchedInTranslation
‪valueOfUniqueFieldExcludedInTranslationIsUntouchedInTranslation()
Definition: GetUniqueTranslationTest.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\GetUniqueTranslationTest\valueOfUniqueFieldExcludedInTranslationIsUntouchedInOriginalLanguage
‪valueOfUniqueFieldExcludedInTranslationIsUntouchedInOriginalLanguage()
Definition: GetUniqueTranslationTest.php:65
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:201