‪TYPO3CMS  9.5
LocalizationRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
21 
25 class ‪LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
26 {
30  protected ‪$subject;
31 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38 
39  $this->setUpBackendUserFromFixture(1);
41 
42  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/DefaultPagesAndContent.csv');
43 
44  $this->subject = new ‪LocalizationRepository();
45  }
46 
50  public function ‪fetchOriginLanguageDataProvider(): array
51  {
52  return [
53  'default language returns empty array' => [
54  1,
55  0,
56  []
57  ],
58  'connected mode translated from default language' => [
59  1,
60  1,
61  [
62  'sys_language_uid' => 0
63  ]
64  ],
65  'connected mode translated from non default language' => [
66  1,
67  2,
68  [
69  'sys_language_uid' => 1
70  ]
71  ],
72  'free mode translated from default language' => [
73  2,
74  1,
75  [
76  'sys_language_uid' => 0
77  ]
78  ],
79  'free mode translated from non default language' => [
80  2,
81  2,
82  [
83  'sys_language_uid' => 1
84  ]
85  ],
86  'free mode copied from another page translated from default language' => [
87  3,
88  1,
89  [
90  'sys_language_uid' => 0
91  ]
92  ],
93  'free mode copied from another page translated from non default language' => [
94  3,
95  2,
96  [
97  'sys_language_uid' => 1
98  ]
99  ]
100  ];
101  }
102 
110  public function ‪fetchOriginLanguage(int $pageId, int $localizedLanguage, ?array $expectedResult): void
111  {
112  $result = $this->subject->fetchOriginLanguage($pageId, $localizedLanguage);
113  $this->assertEquals($expectedResult, $result);
114  }
115 
119  public function ‪getLocalizedRecordCountDataProvider(): array
120  {
121  return [
122  'default language returns 0 always' => [
123  1,
124  0,
125  0
126  ],
127  'connected mode translated from default language' => [
128  1,
129  1,
130  2
131  ],
132  'connected mode translated from non default language' => [
133  1,
134  2,
135  1
136  ],
137  'free mode translated from default language' => [
138  2,
139  1,
140  1
141  ],
142  'free mode translated from non default language' => [
143  2,
144  2,
145  1
146  ],
147  'free mode copied from another page translated from default language' => [
148  3,
149  1,
150  1
151  ],
152  'free mode copied from another page translated from non default language' => [
153  3,
154  2,
155  1
156  ]
157  ];
158  }
159 
167  public function ‪getLocalizedRecordCount(int $pageId, int $localizedLanguage, int $expectedResult): void
168  {
169  $result = $this->subject->getLocalizedRecordCount($pageId, $localizedLanguage);
170  $this->assertEquals($expectedResult, $result);
171  }
172 
176  public function ‪getRecordsToCopyDatabaseResultDataProvider(): array
177  {
178  return [
179  'from language 0 to 1 connected mode' => [
180  1,
181  1,
182  0,
183  [
184  ['uid' => 298]
185  ]
186  ],
187  'from language 1 to 2 connected mode' => [
188  1,
189  2,
190  1,
191  [
192  ['uid' => 300]
193  ]
194  ],
195  'from language 0 to 1 free mode' => [
196  2,
197  1,
198  0,
199  []
200  ],
201  'from language 1 to 2 free mode' => [
202  2,
203  2,
204  1,
205  []
206  ],
207  'from language 0 to 1 free mode copied' => [
208  3,
209  1,
210  0,
211  []
212  ],
213  'from language 1 to 2 free mode mode copied' => [
214  3,
215  2,
216  1,
217  []
218  ],
219  ];
220  }
221 
230  public function ‪getRecordsToCopyDatabaseResult(int $pageId, int $destLanguageId, int $languageId, array $expectedResult): void
231  {
232  $result = $this->subject->getRecordsToCopyDatabaseResult($pageId, $destLanguageId, $languageId, 'uid');
233  $result = $result->fetchAll();
234  $this->assertEquals($expectedResult, $result);
235  }
236 }
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\$subject
‪LocalizationRepository $subject
Definition: LocalizationRepositoryTest.php:29
‪TYPO3\CMS\Backend\Domain\Repository\Localization\LocalizationRepository
Definition: LocalizationRepository.php:35
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization
Definition: LocalizationRepositoryTest.php:4
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getRecordsToCopyDatabaseResult
‪getRecordsToCopyDatabaseResult(int $pageId, int $destLanguageId, int $languageId, array $expectedResult)
Definition: LocalizationRepositoryTest.php:229
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getLocalizedRecordCount
‪getLocalizedRecordCount(int $pageId, int $localizedLanguage, int $expectedResult)
Definition: LocalizationRepositoryTest.php:166
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\setUp
‪setUp()
Definition: LocalizationRepositoryTest.php:34
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getLocalizedRecordCountDataProvider
‪array getLocalizedRecordCountDataProvider()
Definition: LocalizationRepositoryTest.php:118
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\fetchOriginLanguage
‪fetchOriginLanguage(int $pageId, int $localizedLanguage, ?array $expectedResult)
Definition: LocalizationRepositoryTest.php:109
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest
Definition: LocalizationRepositoryTest.php:26
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\getRecordsToCopyDatabaseResultDataProvider
‪array getRecordsToCopyDatabaseResultDataProvider()
Definition: LocalizationRepositoryTest.php:175
‪TYPO3\CMS\Backend\Tests\Functional\Domain\Repository\Localization\LocalizationRepositoryTest\fetchOriginLanguageDataProvider
‪array fetchOriginLanguageDataProvider()
Definition: LocalizationRepositoryTest.php:49
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static Bootstrap null initializeLanguageObject()
Definition: Bootstrap.php:986