TYPO3 CMS  TYPO3_7-6
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 
20 
25 {
29  protected $subject;
30 
34  protected function setUp()
35  {
36  parent::setUp();
37 
38  $this->setUpBackendUserFromFixture(1);
39  Bootstrap::getInstance()->initializeLanguageObject();
40 
41  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/DefaultPagesAndContent.csv');
42 
43  $this->subject = new LocalizationRepository();
44  }
45 
47  {
48  return [
49  'default language returns 0' => [
50  1,
51  0,
52  0,
53  [
54  'sys_language_uid' => 0
55  ]
56  ],
57  'connected mode translated from default language' => [
58  1,
59  0,
60  1,
61  [
62  'sys_language_uid' => 0
63  ]
64  ],
65  'connected mode translated from non default language' => [
66  1,
67  0,
68  2,
69  [
70  'sys_language_uid' => 1
71  ]
72  ],
73  'free mode translated from default language' => [
74  2,
75  0,
76  1,
77  [
78  'sys_language_uid' => 0
79  ]
80  ],
81  'free mode translated from non default language' => [
82  2,
83  0,
84  2,
85  [
86  'sys_language_uid' => 1
87  ]
88  ],
89  'free mode copied from another page translated from default language' => [
90  3,
91  0,
92  1,
93  [
94  'sys_language_uid' => 0
95  ]
96  ],
97  'free mode copied from another page translated from non default language' => [
98  3,
99  0,
100  2,
101  [
102  'sys_language_uid' => 0
103  ]
104  ]
105  ];
106  }
107 
117  public function fetchOriginLanguage($pageId, $colPos, $localizedLanguage, $expectedResult)
118  {
119  $result = $this->subject->fetchOriginLanguage($pageId, $colPos, $localizedLanguage);
120  $this->assertEquals($expectedResult, $result);
121  }
122 
124  {
125  return [
126  'default language returns 0 always' => [
127  1,
128  0,
129  0,
130  0
131  ],
132  'connected mode translated from default language' => [
133  1,
134  0,
135  1,
136  2
137  ],
138  'connected mode translated from non default language' => [
139  1,
140  0,
141  2,
142  1
143  ],
144  'free mode translated from default language' => [
145  2,
146  0,
147  1,
148  1
149  ],
150  'free mode translated from non default language' => [
151  2,
152  0,
153  2,
154  1
155  ],
156  'free mode copied from another page translated from default language' => [
157  3,
158  0,
159  1,
160  1
161  ],
162  'free mode copied from another page translated from non default language' => [
163  3,
164  0,
165  2,
166  1
167  ]
168  ];
169  }
170 
179  public function getLocalizedRecordCount($pageId, $colPos, $localizedLanguage, $expectedResult)
180  {
181  $result = $this->subject->getLocalizedRecordCount($pageId, $colPos, $localizedLanguage);
182  $this->assertEquals($expectedResult, $result);
183  }
184 
186  {
187  return [
188  'from language 0 to 1 connected mode' => [
189  1,
190  0,
191  1,
192  0,
193  [
194  ['uid' => 298]
195  ]
196  ],
197  'from language 1 to 2 connected mode' => [
198  1,
199  0,
200  2,
201  1,
202  [
203  ['uid' => 300]
204  ]
205  ],
206  'from language 0 to 1 free mode' => [
207  2,
208  0,
209  1,
210  0,
211  []
212  ],
213  'from language 1 to 2 free mode' => [
214  2,
215  0,
216  2,
217  1,
218  []
219  ],
220  'from language 0 to 1 free mode copied' => [
221  3,
222  0,
223  1,
224  0,
225  [
226  // this is wrong in terms of usability as we have a translation
227  // already for this record, but in v7.6 there is no way to find
228  // this out, since the record has been copied from page 2
229  // and therefore t3_origuid has been overridden by the copy action
230  ['uid' => 313]
231  ]
232  ],
233  'from language 1 to 2 free mode mode copied' => [
234  3,
235  0,
236  2,
237  1,
238  [
239  // this is wrong in terms of usability as we have a translation
240  // already for this record (from language 1), but in v7.6 there is no way to find
241  // this out, since the record has been copied from page 2
242  // and therefore t3_origuid has been overridden by the copy action
243  ['uid' => 314]
244  ]
245  ],
246  ];
247  }
248 
258  public function getRecordsToCopyDatabaseResult($pageId, $colPos, $destLanguageId, $languageId, $expectedResult)
259  {
260  $result = $this->subject->getRecordsToCopyDatabaseResult($pageId, $colPos, $destLanguageId, $languageId, 'uid');
261  $result = $result->fetch_all(MYSQLI_ASSOC);
262  $this->assertEquals($expectedResult, $result);
263  }
264 }
getRecordsToCopyDatabaseResult($pageId, $colPos, $destLanguageId, $languageId, $expectedResult)