TYPO3 CMS  TYPO3_8-7
LocalizationRepositoryTest.php
Go to the documentation of this file.
1 <?php
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 
19 
23 class LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
24 {
28  protected $subject;
29 
33  protected function setUp()
34  {
35  parent::setUp();
36 
37  $this->setUpBackendUserFromFixture(1);
38  Bootstrap::getInstance()->initializeLanguageObject();
39 
40  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/DefaultPagesAndContent.csv');
41 
42  $this->subject = new LocalizationRepository();
43  }
44 
46  {
47  return [
48  'default language returns false' => [
49  1,
50  0,
51  0,
52  false,
53  ],
54  'connected mode translated from default language' => [
55  1,
56  0,
57  1,
58  [
59  'sys_language_uid' => 0,
60  ],
61  ],
62  'connected mode translated from non default language' => [
63  1,
64  0,
65  2,
66  [
67  'sys_language_uid' => 1,
68  ],
69  ],
70  'free mode translated from default language' => [
71  2,
72  0,
73  1,
74  [
75  'sys_language_uid' => 0,
76  ],
77  ],
78  'free mode translated from non default language' => [
79  2,
80  0,
81  2,
82  [
83  'sys_language_uid' => 1,
84  ],
85  ],
86  'free mode copied from another page translated from default language' => [
87  3,
88  0,
89  1,
90  [
91  'sys_language_uid' => 0,
92  ],
93  ],
94  'free mode copied from another page translated from non default language' => [
95  3,
96  0,
97  2,
98  [
99  'sys_language_uid' => 1,
100  ],
101  ],
102  ];
103  }
104 
114  public function fetchOriginLanguage($pageId, $colPos, $localizedLanguage, $expectedResult)
115  {
116  $result = $this->subject->fetchOriginLanguage($pageId, $colPos, $localizedLanguage);
117  $this->assertEquals($expectedResult, $result);
118  }
119 
121  {
122  return [
123  'default language returns 0 always' => [
124  1,
125  0,
126  0,
127  0,
128  ],
129  'connected mode translated from default language' => [
130  1,
131  0,
132  1,
133  2,
134  ],
135  'connected mode translated from non default language' => [
136  1,
137  0,
138  2,
139  1,
140  ],
141  'free mode translated from default language' => [
142  2,
143  0,
144  1,
145  1,
146  ],
147  'free mode translated from non default language' => [
148  2,
149  0,
150  2,
151  1,
152  ],
153  'free mode copied from another page translated from default language' => [
154  3,
155  0,
156  1,
157  1,
158  ],
159  'free mode copied from another page translated from non default language' => [
160  3,
161  0,
162  2,
163  1,
164  ],
165  ];
166  }
167 
172  public function getLocalizedRecordCount($pageId, $colPos, $localizedLanguage, $expectedResult)
173  {
174  $result = $this->subject->getLocalizedRecordCount($pageId, $colPos, $localizedLanguage);
175  $this->assertEquals($expectedResult, $result);
176  }
177 
179  {
180  return [
181  'from language 0 to 1 connected mode' => [
182  1,
183  0,
184  1,
185  0,
186  [
187  ['uid' => 298],
188  ],
189  ],
190  'from language 1 to 2 connected mode' => [
191  1,
192  0,
193  2,
194  1,
195  [
196  ['uid' => 300],
197  ],
198  ],
199  'from language 0 to 1 free mode' => [
200  2,
201  0,
202  1,
203  0,
204  [],
205  ],
206  'from language 1 to 2 free mode' => [
207  2,
208  0,
209  2,
210  1,
211  [],
212  ],
213  'from language 0 to 1 free mode copied' => [
214  3,
215  0,
216  1,
217  0,
218  [],
219  ],
220  'from language 1 to 2 free mode mode copied' => [
221  3,
222  0,
223  2,
224  1,
225  [],
226  ],
227  ];
228  }
229 
234  public function getRecordsToCopyDatabaseResult($pageId, $colPos, $destLanguageId, $languageId, $expectedResult)
235  {
236  $result = $this->subject->getRecordsToCopyDatabaseResult($pageId, $colPos, $destLanguageId, $languageId, 'uid');
237  $result = $result->fetchAll();
238  $this->assertEquals($expectedResult, $result);
239  }
240 }
getRecordsToCopyDatabaseResult($pageId, $colPos, $destLanguageId, $languageId, $expectedResult)