‪TYPO3CMS  10.4
LocalizationRepositoryTest.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\TestingFramework\Core\Functional\FunctionalTestCase;
23 
27 class ‪LocalizationRepositoryTest extends FunctionalTestCase
28 {
32  protected ‪$subject;
33 
37  protected function ‪setUp(): void
38  {
39  parent::setUp();
40 
41  $this->setUpBackendUserFromFixture(1);
43 
44  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/DefaultPagesAndContent.csv');
45 
46  $this->subject = new ‪LocalizationRepository();
47  }
48 
52  public function ‪fetchOriginLanguageDataProvider(): array
53  {
54  return [
55  'default language returns empty array' => [
56  1,
57  0,
58  []
59  ],
60  'connected mode translated from default language' => [
61  1,
62  1,
63  [
64  'sys_language_uid' => 0
65  ]
66  ],
67  'connected mode translated from non default language' => [
68  1,
69  2,
70  [
71  'sys_language_uid' => 1
72  ]
73  ],
74  'free mode translated from default language' => [
75  2,
76  1,
77  [
78  'sys_language_uid' => 0
79  ]
80  ],
81  'free mode translated from non default language' => [
82  2,
83  2,
84  [
85  'sys_language_uid' => 1
86  ]
87  ],
88  'free mode copied from another page translated from default language' => [
89  3,
90  1,
91  [
92  'sys_language_uid' => 0
93  ]
94  ],
95  'free mode copied from another page translated from non default language' => [
96  3,
97  2,
98  [
99  'sys_language_uid' => 1
100  ]
101  ]
102  ];
103  }
104 
112  public function ‪fetchOriginLanguage(int $pageId, int $localizedLanguage, ?array $expectedResult): void
113  {
114  $result = $this->subject->fetchOriginLanguage($pageId, $localizedLanguage);
115  self::assertEquals($expectedResult, $result);
116  }
117 
121  public function ‪getLocalizedRecordCountDataProvider(): array
122  {
123  return [
124  'default language returns 0 always' => [
125  1,
126  0,
127  0
128  ],
129  'connected mode translated from default language' => [
130  1,
131  1,
132  2
133  ],
134  'connected mode translated from non default language' => [
135  1,
136  2,
137  1
138  ],
139  'free mode translated from default language' => [
140  2,
141  1,
142  1
143  ],
144  'free mode translated from non default language' => [
145  2,
146  2,
147  1
148  ],
149  'free mode copied from another page translated from default language' => [
150  3,
151  1,
152  1
153  ],
154  'free mode copied from another page translated from non default language' => [
155  3,
156  2,
157  1
158  ]
159  ];
160  }
161 
169  public function ‪getLocalizedRecordCount(int $pageId, int $localizedLanguage, int $expectedResult): void
170  {
171  $result = $this->subject->getLocalizedRecordCount($pageId, $localizedLanguage);
172  self::assertEquals($expectedResult, $result);
173  }
174 
178  public function ‪getRecordsToCopyDatabaseResultDataProvider(): array
179  {
180  return [
181  'from language 0 to 1 connected mode' => [
182  1,
183  1,
184  0,
185  [
186  ['uid' => 298]
187  ]
188  ],
189  'from language 1 to 2 connected mode' => [
190  1,
191  2,
192  1,
193  [
194  ['uid' => 300]
195  ]
196  ],
197  'from language 0 to 1 free mode' => [
198  2,
199  1,
200  0,
201  []
202  ],
203  'from language 1 to 2 free mode' => [
204  2,
205  2,
206  1,
207  []
208  ],
209  'from language 0 to 1 free mode copied' => [
210  3,
211  1,
212  0,
213  []
214  ],
215  'from language 1 to 2 free mode mode copied' => [
216  3,
217  2,
218  1,
219  []
220  ],
221  ];
222  }
223 
232  public function ‪getRecordsToCopyDatabaseResult(int $pageId, int $destLanguageId, int $languageId, array $expectedResult): void
233  {
234  $result = $this->subject->getRecordsToCopyDatabaseResult($pageId, $destLanguageId, $languageId, 'uid');
235  $result = $result->fetchAll();
236  self::assertEquals($expectedResult, $result);
237  }
238 }
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\$subject
‪LocalizationRepository $subject
Definition: LocalizationRepositoryTest.php:31
‪TYPO3\CMS\Backend\Domain\Repository\Localization\LocalizationRepository
Definition: LocalizationRepository.php:37
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization
Definition: LocalizationRepositoryTest.php:18
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getRecordsToCopyDatabaseResult
‪getRecordsToCopyDatabaseResult(int $pageId, int $destLanguageId, int $languageId, array $expectedResult)
Definition: LocalizationRepositoryTest.php:231
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getLocalizedRecordCount
‪getLocalizedRecordCount(int $pageId, int $localizedLanguage, int $expectedResult)
Definition: LocalizationRepositoryTest.php:168
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\setUp
‪setUp()
Definition: LocalizationRepositoryTest.php:36
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:617
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getLocalizedRecordCountDataProvider
‪array getLocalizedRecordCountDataProvider()
Definition: LocalizationRepositoryTest.php:120
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\fetchOriginLanguage
‪fetchOriginLanguage(int $pageId, int $localizedLanguage, ?array $expectedResult)
Definition: LocalizationRepositoryTest.php:111
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest
Definition: LocalizationRepositoryTest.php:28
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getRecordsToCopyDatabaseResultDataProvider
‪array getRecordsToCopyDatabaseResultDataProvider()
Definition: LocalizationRepositoryTest.php:177
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\fetchOriginLanguageDataProvider
‪array fetchOriginLanguageDataProvider()
Definition: LocalizationRepositoryTest.php:51