‪TYPO3CMS  ‪main
L18nDiffsourceToJsonMigrationTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
23 final class ‪L18nDiffsourceToJsonMigrationTest extends UnitTestCase
24 {
29  {
30  ‪$GLOBALS['TCA']['testTable'] = [];
31  self::assertFalse((new ‪L18nDiffsourceToJsonMigration())->hasPotentialUpdateForTable('testTable'));
32  }
33 
38  {
39  ‪$GLOBALS['TCA']['testTable'] = [
40  'ctrl' => [
41  'languageField' => 'sys_language_uid',
42  'transOrigPointerField' => 'l10n_parent',
43  'transOrigDiffSourceField' =>'l10n_diffsource',
44  ],
45  ];
46  self::assertTrue((new ‪L18nDiffsourceToJsonMigration())->hasPotentialUpdateForTable('testTable'));
47  }
48 
53  {
54  ‪$GLOBALS['TCA']['testTable'] = [
55  'ctrl' => [
56  'transOrigDiffSourceField' =>'l10n_diffsource',
57  ],
58  ];
59  $row = [];
60  self::assertSame($row, (new ‪L18nDiffsourceToJsonMigration())->updateTableRow('testTable', $row));
61  }
62 
63  public static function ‪updateTableRowUpdatesFieldDataProvider(): array
64  {
65  $object = new \stdClass();
66  $json = json_encode(['foo' => 'bar']);
67  $serializedArray = serialize(['foo' => 'bar']);
68  $serializedObject = serialize(new \stdClass());
69  return [
70  'null is kept' => [
71  null,
72  null,
73  ],
74  'false is kept' => [
75  false,
76  false,
77  ],
78  'true is kept' => [
79  true,
80  true,
81  ],
82  'string is kept' => [
83  'foo',
84  'foo',
85  ],
86  'array is kept' => [
87  ['foo' => 'bar'],
88  ['foo' => 'bar'],
89  ],
90  'object is kept' => [
91  $object,
92  $object,
93  ],
94  'json is kept' => [
95  $json,
96  $json,
97  ],
98  'serialized object is removed' => [
99  $serializedObject,
100  null,
101  ],
102  'serialized array is migrated' => [
103  $serializedArray,
104  $json,
105  ],
106  ];
107  }
108 
116  public function ‪updateTableRowUpdatesField($input, $expected): void
117  {
118  ‪$GLOBALS['TCA']['testTable'] = [
119  'ctrl' => [
120  'transOrigDiffSourceField' =>'l10n_diffsource',
121  ],
122  ];
123  $row = ['l10n_diffsource' => $input];
124  $expected = ['l10n_diffsource' => $expected];
125  self::assertSame($expected, (new ‪L18nDiffsourceToJsonMigration())->updateTableRow('testTable', $row));
126  }
127 }
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater
Definition: L18nDiffsourceToJsonMigrationTest.php:18
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater\L18nDiffsourceToJsonMigrationTest
Definition: L18nDiffsourceToJsonMigrationTest.php:24
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater\L18nDiffsourceToJsonMigrationTest\updateTableRowDoesNothingIfFieldIsNotSet
‪updateTableRowDoesNothingIfFieldIsNotSet()
Definition: L18nDiffsourceToJsonMigrationTest.php:52
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater\L18nDiffsourceToJsonMigrationTest\hasPotentialUpdateForTableReturnsFalseIfTableIsNotLocalizable
‪hasPotentialUpdateForTableReturnsFalseIfTableIsNotLocalizable()
Definition: L18nDiffsourceToJsonMigrationTest.php:28
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater\L18nDiffsourceToJsonMigrationTest\updateTableRowUpdatesFieldDataProvider
‪static updateTableRowUpdatesFieldDataProvider()
Definition: L18nDiffsourceToJsonMigrationTest.php:63
‪TYPO3\CMS\Install\Updates\RowUpdater\L18nDiffsourceToJsonMigration
Definition: L18nDiffsourceToJsonMigration.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater\L18nDiffsourceToJsonMigrationTest\updateTableRowUpdatesField
‪updateTableRowUpdatesField($input, $expected)
Definition: L18nDiffsourceToJsonMigrationTest.php:116
‪TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater\L18nDiffsourceToJsonMigrationTest\hasPotentialUpdateForTableReturnsTrueIfTableIsLocalizable
‪hasPotentialUpdateForTableReturnsTrueIfTableIsLocalizable()
Definition: L18nDiffsourceToJsonMigrationTest.php:37