‪TYPO3CMS  11.5
TranslationDiffSourceTest.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 use TYPO3\CMS\Backend\Utility\BackendUtility;
25 
27 {
28  protected const ‪PAGE_DATAHANDLER = 88;
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  $this->importCSVDataSet(__DIR__ . '/DataSet/TranslationDiffSourceTest.csv');
34  $this->‪setUpFrontendSite(1, $this->siteLanguageConfiguration);
35  $this->backendUser->workspace = 0;
36  }
37 
42  {
43  $map = $this->actionService->localizeRecord('pages', self::PAGE_DATAHANDLER, 1);
44 
45  $newPageId = $map['pages'][‪self::PAGE_DATAHANDLER];
46  $originalLanguageRecord = BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
47  $translatedRecord = BackendUtility::getRecord('pages', $newPageId);
48  $transOrigDiffSourceField = json_decode($translatedRecord[‪$GLOBALS['TCA']['pages']['ctrl']['transOrigDiffSourceField']], true);
49 
50  self::assertEquals('DataHandlerTest', $originalLanguageRecord['title']);
51  self::assertEquals('DataHandlerTest', $transOrigDiffSourceField['title']);
52  }
53 
58  {
59  $map = $this->actionService->localizeRecord('pages', self::PAGE_DATAHANDLER, 1);
60  $newPageId = $map['pages'][‪self::PAGE_DATAHANDLER];
61  $this->actionService->modifyRecord(
62  'pages',
63  self::PAGE_DATAHANDLER,
64  [
65  'title' => 'Modified dataHandler',
66  ]
67  );
68 
69  $element = 'pages:' . ‪self::PAGE_DATAHANDLER;
70  $recordHistory = GeneralUtility::makeInstance(RecordHistory::class, $element);
71  $changeLog = $recordHistory->getChangeLog();
72  $recordHistoryRollback = GeneralUtility::makeInstance(RecordHistoryRollback::class);
73  $recordHistoryRollback->performRollback($element, $recordHistory->getDiff($changeLog));
74 
75  $record = BackendUtility::getRecord('pages', self::PAGE_DATAHANDLER);
76  $translatedRecord = BackendUtility::getRecord('pages', $newPageId);
77  $transOrigDiffSourceField = json_decode($translatedRecord[‪$GLOBALS['TCA']['pages']['ctrl']['transOrigDiffSourceField']], true);
78 
79  self::assertEmpty($record[‪$GLOBALS['TCA']['pages']['ctrl']['transOrigDiffSourceField']]);
80  self::assertEquals('DataHandlerTest', $transOrigDiffSourceField['title']);
81  }
82 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\TranslationDiffSourceTest\transOrigDiffSourceFieldWrittenAfterTranslation
‪transOrigDiffSourceFieldWrittenAfterTranslation()
Definition: TranslationDiffSourceTest.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler
Definition: DefaultValuesTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:127
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\TranslationDiffSourceTest\transOrigDiffSourceNotUpdatedAfterUndo
‪transOrigDiffSourceNotUpdatedAfterUndo()
Definition: TranslationDiffSourceTest.php:57
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\TranslationDiffSourceTest\PAGE_DATAHANDLER
‪const PAGE_DATAHANDLER
Definition: TranslationDiffSourceTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\TranslationDiffSourceTest\setUp
‪setUp()
Definition: TranslationDiffSourceTest.php:30
‪TYPO3\CMS\Backend\History\RecordHistoryRollback
Definition: RecordHistoryRollback.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:41
‪TYPO3\CMS\Backend\History\RecordHistory
Definition: RecordHistory.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\TranslationDiffSourceTest
Definition: TranslationDiffSourceTest.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50