2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
24 use TYPO3\CMS\Core\Tests\UnitTestCase;
51 $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
52 $GLOBALS[
'TYPO3_DB'] = $this->dbProphecy->reveal();
53 $languageService = $this->prophesize(LanguageService::class);
54 $GLOBALS[
'LANG'] = $languageService->reveal();
55 $languageService->sL(Argument::cetera())->willReturnArgument(0);
71 $this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn(null);
72 $this->dbProphecy->sql_error(Argument::cetera())->willReturn(null);
73 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1438170741);
74 $this->subject->addData([]);
83 'systemLanguageRows' => [
86 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:multipleLanguages',
88 'flagIconIdentifier' =>
'flags-multiple',
92 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage',
94 'flagIconIdentifier' =>
'empty-empty',
98 $this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn([]);
99 $this->assertSame($expected, $this->subject->addData([]));
111 'defaultLanguageLabel' =>
'foo',
116 $this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn([]);
118 $expected[
'systemLanguageRows'] = [
121 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:multipleLanguages',
123 'flagIconIdentifier' =>
'flags-multiple',
127 'title' =>
'foo (LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage)',
129 'flagIconIdentifier' =>
'empty-empty',
132 $this->assertSame($expected, $this->subject->addData($input));
144 'defaultLanguageFlag' =>
'uk',
149 $this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn([]);
151 $expected[
'systemLanguageRows'] = [
154 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:multipleLanguages',
156 'flagIconIdentifier' =>
'flags-multiple',
160 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage',
162 'flagIconIdentifier' =>
'flags-uk',
165 $this->assertSame($expected, $this->subject->addData($input));
177 'language_isocode' =>
'fr',
178 'static_lang_isocode' =>
'',
182 $this->dbProphecy->exec_SELECTgetRows(
'uid,title,language_isocode,static_lang_isocode,flag',
'sys_language',
'pid=0')->willReturn($dbRows);
184 'systemLanguageRows' => [
187 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:multipleLanguages',
189 'flagIconIdentifier' =>
'flags-multiple',
193 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage',
195 'flagIconIdentifier' =>
'empty-empty',
200 'flagIconIdentifier' =>
'flags-fr',
205 $this->assertSame($expected, $this->subject->addData([]));
214 $this->markTestSkipped(
'no ext:static_info_tables available');
220 'language_isocode' =>
'',
221 'static_lang_isocode' => 42,
225 $this->dbProphecy->exec_SELECTgetRows(
'uid,title,language_isocode,static_lang_isocode,flag',
'sys_language',
'pid=0')->shouldBeCalled()->willReturn($dbRows);
227 $GLOBALS[
'TCA'][
'static_languages'] = [
'foo' ];
228 $this->dbProphecy->exec_SELECTgetSingleRow(
'lg_iso_2',
'static_languages',
'uid=42')->shouldBeCalled()->willReturn([
'lg_iso_2' =>
'FR' ]);
230 'systemLanguageRows' => [
233 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:multipleLanguages',
235 'flagIconIdentifier' =>
'flags-multiple',
239 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage',
241 'flagIconIdentifier' =>
'empty-empty',
246 'flagIconIdentifier' =>
'flags-fr',
251 $this->assertSame($expected, $this->subject->addData([]));
257 public function addDataAddFlashMessageWithMissingIsoCode()
263 'language_isocode' =>
'',
264 'static_lang_isocode' =>
'',
268 $this->dbProphecy->exec_SELECTgetRows(
'uid,title,language_isocode,static_lang_isocode,flag',
'sys_language',
'pid=0')->shouldBeCalled()->willReturn($dbRows);
270 $GLOBALS[
'TCA'][
'static_languages'] = [
'foo' ];
272 'systemLanguageRows' => [
275 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:multipleLanguages',
277 'flagIconIdentifier' =>
'flags-multiple',
281 'title' =>
'LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage',
283 'flagIconIdentifier' =>
'empty-empty',
288 'flagIconIdentifier' =>
'flags-fr',
295 $flashMessage = $this->prophesize(FlashMessage::class);
298 $flashMessageService = $this->prophesize(FlashMessageService::class);
301 $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
302 $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
304 $flashMessageQueue->enqueue($flashMessage)->shouldBeCalled();
306 $this->assertSame($expected, $this->subject->addData([]));