[BUGFIX] Set l10n_state before synchronizing fields
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Functional / Updates / RowUpdater / L10nModeUpdaterTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Functional\Updates\RowUpdater;
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
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Install\Updates\RowUpdater\L10nModeUpdater;
19 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
20
21 /**
22 * Test Class for L10nModeUpdater
23 */
24 class L10nModeUpdaterTest extends FunctionalTestCase
25 {
26 /**
27 * @var string
28 */
29 protected $scenarioDataSetDirectory = 'typo3/sysext/install/Tests/Functional/Updates/RowUpdater/DataSet/';
30
31 /**
32 * @var string
33 */
34 protected $assertionDataSetDirectory = 'typo3/sysext/install/Tests/Functional/Updates/RowUpdater/DataSet/';
35
36 /**
37 * @var string[]
38 */
39 protected $coreExtensionsToLoad = [
40 'workspaces',
41 ];
42
43 /**
44 * @var string[]
45 */
46 protected $testExtensionsToLoad = [
47 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
48 ];
49
50 protected function setUp()
51 {
52 parent::setUp();
53 $this->importScenarioDataSet('LiveDefaultPages');
54 $this->importScenarioDataSet('LiveDefaultElements');
55
56 $GLOBALS['TCA']['tt_content']['columns']['image']['l10n_mode'] = 'exclude';
57 $GLOBALS['TCA']['tt_content']['columns']['header']['config']['behaviour']['allowLanguageSynchronization'] = true;
58 $GLOBALS['TCA']['tt_content']['columns']['tx_irretutorial_1nff_hotels']['config']['behaviour']['allowLanguageSynchronization'] = true;
59 }
60
61 /**
62 * @param string $dataSetName
63 */
64 protected function importScenarioDataSet($dataSetName)
65 {
66 $fileName = rtrim($this->scenarioDataSetDirectory, '/') . '/' . $dataSetName . '.csv';
67 $fileName = GeneralUtility::getFileAbsFileName($fileName);
68 $this->importCSVDataSet($fileName);
69 }
70
71 protected function assertAssertionDataSet($dataSetName)
72 {
73 $fileName = rtrim($this->assertionDataSetDirectory, '/') . '/' . $dataSetName . '.csv';
74 $fileName = GeneralUtility::getFileAbsFileName($fileName);
75 $this->assertCSVDataSet($fileName);
76 }
77
78 /**
79 * @return array
80 */
81 protected function getTableNames(): array
82 {
83 return array_keys($GLOBALS['TCA']);
84 }
85
86 /**
87 * @test
88 */
89 public function recordsCanBeUpdated()
90 {
91 $updater = new L10nModeUpdater();
92 foreach ($this->getTableNames() as $tableName) {
93 $updater->hasPotentialUpdateForTable($tableName);
94 foreach ($this->getAllRecords($tableName) as $record) {
95 $updater->updateTableRow($tableName, $record);
96 }
97 }
98
99 $this->assertAssertionDataSet('recordsCanBeUpdated');
100 }
101 }