TYPO3 CMS  TYPO3_7-6
LocalizationControllerTest.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 
21 
26 {
30  protected $subject;
31 
37  protected function setUp()
38  {
39  parent::setUp();
40 
41  $this->setUpBackendUserFromFixture(1);
42  Bootstrap::getInstance()->initializeLanguageObject();
43 
44  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Fixtures/pages.xml');
45  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/sys_language.xml');
46  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Controller/Page/Fixtures/tt_content-default-language.xml');
47 
48  $this->subject = new LocalizationController();
49  }
50 
55  {
56  $params = [
57  'pageId' => 1,
58  'srcLanguageId' => 0,
59  'destLanguageId' => 1,
60  'uidList' => [1, 2, 3],
62  ];
63  $this->callInaccessibleMethod($this->subject, 'process', $params);
64 
65  $expectedResults = [
66  [
67  'pid' => '1',
68  'sys_language_uid' => '1',
69  'l18n_parent' => '1',
70  'header' => '[Translate to Dansk:] Test content 1',
71  ],
72  [
73  'pid' => '1',
74  'sys_language_uid' => '1',
75  'l18n_parent' => '2',
76  'header' => '[Translate to Dansk:] Test content 2',
77  ],
78  [
79  'pid' => '1',
80  'sys_language_uid' => '1',
81  'l18n_parent' => '3',
82  'header' => '[Translate to Dansk:] Test content 3',
83  ],
84  ];
85  $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 1');
86  $this->assertSame($expectedResults, $results);
87  }
88 
93  {
94  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Controller/Page/Fixtures/tt_content-danish-language.xml');
95 
96  $params = [
97  'pageId' => 1,
98  'srcLanguageId' => 1,
99  'destLanguageId' => 2,
100  'uidList' => [4, 5, 6], // uids of tt_content-danish-language
102  ];
103  $this->callInaccessibleMethod($this->subject, 'process', $params);
104 
105  $expectedResults = [
106  [
107  'pid' => '1',
108  'sys_language_uid' => '2',
109  'l18n_parent' => '1',
110  'header' => '[Translate to Deutsch:] Test indhold 1',
111  ],
112  [
113  'pid' => '1',
114  'sys_language_uid' => '2',
115  'l18n_parent' => '2',
116  'header' => '[Translate to Deutsch:] Test indhold 2',
117  ],
118  [
119  'pid' => '1',
120  'sys_language_uid' => '2',
121  'l18n_parent' => '3',
122  'header' => '[Translate to Deutsch:] Test indhold 3',
123  ],
124  ];
125  $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 2');
126  $this->assertSame($expectedResults, $results);
127  }
128 
133  {
134  $params = [
135  'pageId' => 1,
136  'srcLanguageId' => 0,
137  'destLanguageId' => 2,
138  'uidList' => [1, 2, 3],
140  ];
141  $this->callInaccessibleMethod($this->subject, 'process', $params);
142 
143  $expectedResults = [
144  [
145  'pid' => '1',
146  'sys_language_uid' => '2',
147  'l18n_parent' => '0',
148  'header' => '[Translate to Deutsch:] Test content 1',
149  ],
150  [
151  'pid' => '1',
152  'sys_language_uid' => '2',
153  'l18n_parent' => '0',
154  'header' => '[Translate to Deutsch:] Test content 2',
155  ],
156  [
157  'pid' => '1',
158  'sys_language_uid' => '2',
159  'l18n_parent' => '0',
160  'header' => '[Translate to Deutsch:] Test content 3',
161  ],
162  ];
163  $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 2');
164  $this->assertSame($expectedResults, $results);
165  }
166 
171  {
172  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Controller/Page/Fixtures/tt_content-danish-language.xml');
173 
174  $params = [
175  'pageId' => 1,
176  'srcLanguageId' => 1,
177  'destLanguageId' => 2,
178  'uidList' => [4, 5, 6], // uids of tt_content-danish-language
180  ];
181  $this->callInaccessibleMethod($this->subject, 'process', $params);
182 
183  $expectedResults = [
184  [
185  'pid' => '1',
186  'sys_language_uid' => '2',
187  'l18n_parent' => '0',
188  'header' => '[Translate to Deutsch:] Test indhold 1',
189  ],
190  [
191  'pid' => '1',
192  'sys_language_uid' => '2',
193  'l18n_parent' => '0',
194  'header' => '[Translate to Deutsch:] Test indhold 2',
195  ],
196  [
197  'pid' => '1',
198  'sys_language_uid' => '2',
199  'l18n_parent' => '0',
200  'header' => '[Translate to Deutsch:] Test indhold 3',
201  ],
202  ];
203  $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 2');
204  $this->assertSame($expectedResults, $results);
205  }
206 
211  {
212  $params = [
213  'pageId' => 1,
214  'srcLanguageId' => 0,
215  'destLanguageId' => 1,
216  'uidList' => [1, 2, 3],
218  ];
219  $this->callInaccessibleMethod($this->subject, 'process', $params);
220 
221  // Create another content element in default language
222  $data = [
223  'tt_content' => [
224  'NEW123456' => [
225  'sys_language_uid' => 0,
226  'header' => 'Test content 2.5',
227  'pid' => -2,
228  ],
229  ],
230  ];
231  $dataHandler = new DataHandler();
232  $dataHandler->start($data, []);
233  $dataHandler->process_datamap();
234  $dataHandler->process_cmdmap();
235  $newContentElementUid = $dataHandler->substNEWwithIDs['NEW123456'];
236 
237  // Copy the new content element
238  $params = [
239  'pageId' => 1,
240  'srcLanguageId' => 0,
241  'destLanguageId' => 1,
242  'uidList' => [$newContentElementUid],
244  ];
245  $this->callInaccessibleMethod($this->subject, 'process', $params);
246 
247  $expectedResults = [
248  [
249  'pid' => '1',
250  'sys_language_uid' => '1',
251  'l18n_parent' => '0',
252  'header' => '[Translate to Dansk:] Test content 1',
253  ],
254  [
255  'pid' => '1',
256  'sys_language_uid' => '1',
257  'l18n_parent' => '0',
258  'header' => '[Translate to Dansk:] Test content 2.5',
259  ],
260  [
261  'pid' => '1',
262  'sys_language_uid' => '1',
263  'l18n_parent' => '0',
264  'header' => '[Translate to Dansk:] Test content 2',
265  ],
266  [
267  'pid' => '1',
268  'sys_language_uid' => '1',
269  'l18n_parent' => '0',
270  'header' => '[Translate to Dansk:] Test content 3',
271  ],
272  ];
273  $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 1', '', 'sorting ASC');
274  $this->assertSame($expectedResults, $results);
275  }
276 }