‪TYPO3CMS  9.5
TranslationServiceTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Prophecy\Argument;
31 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
32 
36 class ‪TranslationServiceTest extends UnitTestCase
37 {
41  protected ‪$resetSingletonInstances = true;
42 
47 
52 
56  protected ‪$store;
57 
61  public function ‪setUp()
62  {
63  $this->resetSingletonInstances = true;
64  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
65  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
66  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
67  $cacheManagerProphecy->getCache('l10n')->willReturn($cacheFrontendProphecy->reveal());
68  $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
69  $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
70 
71  $localizationFactory = $this->prophesize(LocalizationFactory::class);
72  $localizationFactory
73  ->getParsedData('EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf', 'default')
74  ->willReturn(include __DIR__ . '/Fixtures/locallang_form.php');
75  $localizationFactory
76  ->getParsedData('EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf', 'de')
77  ->willReturn(include __DIR__ . '/Fixtures/de.locallang_form.php');
78  $localizationFactory
79  ->getParsedData('EXT:form/Tests/Unit/Service/Fixtures/locallang_additional_text.xlf', 'default')
80  ->willReturn(include __DIR__ . '/Fixtures/locallang_additional_text.php');
81  $localizationFactory
82  ->getParsedData('EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_01.xlf', 'default')
83  ->willReturn(include __DIR__ . '/Fixtures/locallang_ceuid_suffix_01.php');
84  $localizationFactory
85  ->getParsedData('EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_02.xlf', 'default')
86  ->willReturn(include __DIR__ . '/Fixtures/locallang_ceuid_suffix_02.php');
87  $localizationFactory
88  ->getParsedData('EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf', 'default')
89  ->willReturn(include __DIR__ . '/Fixtures/locallang_text.php');
90 
91  GeneralUtility::setSingletonInstance(LocalizationFactory::class, $localizationFactory->reveal());
92 
93  $this->mockConfigurationManager = $this->getAccessibleMock(ConfigurationManager::class, [
94  'getConfiguration'
95  ], [], '', false);
96 
97  $this->mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
98  'getConfigurationManager',
99  'getLanguageService'
100  ], [], '', false);
101 
102  $this->mockTranslationService
103  ->expects($this->any())
104  ->method('getLanguageService')
105  ->willReturn(GeneralUtility::makeInstance(LanguageService::class));
106 
107  $this->mockTranslationService
108  ->expects($this->any())
109  ->method('getConfigurationManager')
110  ->willReturn($this->mockConfigurationManager);
111 
112  $this->store = GeneralUtility::makeInstance(LanguageStore::class);
113  $this->store->initialize();
114  }
115 
120  {
121  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
122  $expected = 'FORM EN';
123 
124  $this->store->flushData($xlfPath);
125  $this->assertEquals($expected, $this->mockTranslationService->_call(
126  'translate',
127  $xlfPath . ':element.Page.renderingOptions.nextButtonLabel'
128  ));
129  }
130 
135  {
136  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
137  $expected = 'FORM EN';
138 
139  $this->store->flushData($xlfPath);
140  $this->assertEquals($expected, $this->mockTranslationService->_call(
141  'translate',
142  'LLL:' . $xlfPath . ':element.Page.renderingOptions.nextButtonLabel'
143  ));
144  }
145 
150  {
151  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
152  $expected = 'FORM EN';
153 
154  $this->store->flushData($xlfPath);
155  $this->assertEquals($expected, $this->mockTranslationService->_call(
156  'translate',
157  $xlfPath . ':element.Page.renderingOptions.nextButtonLabel',
158  null,
159  null,
160  null,
161  'defaultValue'
162  ));
163  }
164 
169  {
170  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
171  $this->store->flushData($xlfPath);
172 
173  $expected = '';
174  $this->assertEquals($expected, $this->mockTranslationService->_call(
175  'translate',
176  $xlfPath . ':element.Page.renderingOptions.nonExisting'
177  ));
178  }
179 
184  {
185  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
186  $this->store->flushData($xlfPath);
187 
188  $expected = 'defaultValue';
189  $this->assertEquals($expected, $this->mockTranslationService->_call(
190  'translate',
191  $xlfPath . ':element.Page.renderingOptions.nonExisting',
192  null,
193  null,
194  null,
195  'defaultValue'
196  ));
197  }
198 
203  {
204  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
205  $expected = 'FORM DE';
206 
207  $this->store->flushData($xlfPath);
208  $this->assertEquals($expected, $this->mockTranslationService->_call(
209  'translate',
210  $xlfPath . ':element.Page.renderingOptions.nextButtonLabel',
211  null,
212  null,
213  'de'
214  ));
215  }
216 
221  {
222  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
223  $expected = 'defaultValue';
224 
225  $this->store->flushData($xlfPath);
226  $this->assertEquals($expected, $this->mockTranslationService->_call(
227  'translate',
228  $xlfPath . ':element.Page.renderingOptions.nonExisting',
229  null,
230  null,
231  'de',
232  'defaultValue'
233  ));
234  }
235 
240  {
241  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
242  $expected = '';
243 
244  $this->store->flushData($xlfPath);
245  $this->assertEquals($expected, $this->mockTranslationService->_call(
246  'translate',
247  $xlfPath . ':element.Page.renderingOptions.nonExisting',
248  null,
249  null,
250  'de'
251  ));
252  }
253 
258  {
259  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
260  $expected = 'FORM EN';
261 
262  $this->store->flushData($xlfPath);
263  $this->assertEquals($expected, $this->mockTranslationService->_call(
264  'translate',
265  'element.Page.renderingOptions.nextButtonLabel',
266  null,
267  $xlfPath
268  ));
269  }
270 
275  {
276  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
277  $expected = 'FORM EN';
278 
279  $this->store->flushData($xlfPath);
280  $this->assertEquals($expected, $this->mockTranslationService->_call(
281  'translate',
282  'element.Page.renderingOptions.nextButtonLabel',
283  null,
284  'LLL:' . $xlfPath
285  ));
286  }
287 
291  public function ‪translateValuesRecursiveTranslateRecursive(): void
292  {
293  $xlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
294 
295  $input = [
296  'Stan' => [
297  'Steve' => 'Roger'
298  ],
299  [
300  'Francine' => [
301  'Klaus' => 'element.Page.renderingOptions.nextButtonLabel'
302  ],
303  ],
304  ];
305 
306  $expected = [
307  'Stan' => [
308  'Steve' => 'Roger'
309  ],
310  [
311  'Francine' => [
312  'Klaus' => 'FORM EN'
313  ],
314  ],
315  ];
316 
317  $this->store->flushData($xlfPath);
318  $this->assertEquals($expected, $this->mockTranslationService->_call(
319  'translateValuesRecursive',
320  $input,
321  $xlfPath
322  ));
323  }
324 
329  {
330  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
331  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
332 
333  $formRuntimeIdentifier = 'form-runtime-identifier';
334  $formElementIdentifier = 'form-element-identifier';
335 
336  $formRuntimeRenderingOptions = [
337  'translation' => [
338  'translationFile' => $formRuntimeXlfPath,
339  'translatePropertyValueIfEmpty' => true
340  ],
341  ];
342 
343  $formElementRenderingOptions = [
344  'translation' => [
345  'translationFile' => $textElementXlfPath,
346  'translatePropertyValueIfEmpty' => true
347  ],
348  ];
349 
350  $expected = 'form-element-identifier LABEL EN';
351 
352  $this->store->flushData($formRuntimeXlfPath);
353  $this->store->flushData($textElementXlfPath);
354 
355  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
356 
357  $mockFormElement->_set('type', 'Text');
358  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
359  $mockFormElement->_set('identifier', $formElementIdentifier);
360  $mockFormElement->_set('label', 'some label');
361 
362  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
363  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
364  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
365 
366  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
367  }
368 
373  {
374  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
375  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
376 
377  $formRuntimeIdentifier = 'form-runtime-identifier';
378  $formElementIdentifier = 'form-element-identifier';
379 
380  $formRuntimeRenderingOptions = [
381  'translation' => [
382  'translationFile' => $formRuntimeXlfPath,
383  'translatePropertyValueIfEmpty' => true
384  ],
385  ];
386 
387  $formElementRenderingOptions = [
388  'translation' => [
389  'translationFile' => $textElementXlfPath,
390  'translatePropertyValueIfEmpty' => true
391  ],
392  ];
393 
394  $expected = 'form-element-identifier LABEL EN';
395 
396  $this->store->flushData($formRuntimeXlfPath);
397  $this->store->flushData($textElementXlfPath);
398 
399  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
400 
401  $mockFormElement->_set('type', 'Text');
402  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
403  $mockFormElement->_set('identifier', $formElementIdentifier);
404  $mockFormElement->_set('label', '');
405 
406  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
407  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
408  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
409 
410  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
411  }
412 
417  {
418  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
419  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
420 
421  $formRuntimeIdentifier = 'form-runtime-identifier';
422  $formElementIdentifier = 'form-element-identifier';
423 
424  $formRuntimeRenderingOptions = [
425  'translation' => [
426  'translationFile' => $formRuntimeXlfPath,
427  'translatePropertyValueIfEmpty' => true
428  ],
429  ];
430 
431  $formElementRenderingOptions = [
432  'translation' => [
433  'translationFile' => $textElementXlfPath,
434  'translatePropertyValueIfEmpty' => false
435  ],
436  ];
437 
438  $expected = '';
439 
440  $this->store->flushData($formRuntimeXlfPath);
441  $this->store->flushData($textElementXlfPath);
442 
443  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
444 
445  $mockFormElement->_set('type', 'Text');
446  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
447  $mockFormElement->_set('identifier', $formElementIdentifier);
448  $mockFormElement->_set('label', '');
449 
450  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
451  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
452  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
453 
454  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
455  }
456 
461  {
462  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
463  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
464 
465  $formRuntimeIdentifier = 'another-form-runtime-identifier';
466  $formElementIdentifier = 'form-element-identifier';
467 
468  $formRuntimeRenderingOptions = [
469  'translation' => [
470  'translationFile' => $formRuntimeXlfPath,
471  'translatePropertyValueIfEmpty' => true
472  ],
473  ];
474 
475  $formElementRenderingOptions = [
476  'translation' => [
477  'translationFile' => $textElementXlfPath,
478  'translatePropertyValueIfEmpty' => true
479  ],
480  ];
481 
482  $expected = 'form-element-identifier LABEL EN 1';
483 
484  $this->store->flushData($formRuntimeXlfPath);
485  $this->store->flushData($textElementXlfPath);
486 
487  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
488 
489  $mockFormElement->_set('type', 'Text');
490  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
491  $mockFormElement->_set('identifier', $formElementIdentifier);
492  $mockFormElement->_set('label', 'some label');
493 
494  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
495  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
496  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
497 
498  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
499  }
500 
505  {
506  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
507  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
508 
509  $formRuntimeIdentifier = 'another-form-runtime-identifier';
510  $formElementIdentifier = 'another-form-element-identifier';
511 
512  $formRuntimeRenderingOptions = [
513  'translation' => [
514  'translationFile' => $formRuntimeXlfPath,
515  'translatePropertyValueIfEmpty' => true
516  ],
517  ];
518 
519  $formElementRenderingOptions = [
520  'translation' => [
521  'translationFile' => $textElementXlfPath,
522  'translatePropertyValueIfEmpty' => true
523  ],
524  ];
525 
526  $expected = 'form-element-identifier LABEL EN 2';
527 
528  $this->store->flushData($formRuntimeXlfPath);
529  $this->store->flushData($textElementXlfPath);
530 
531  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
532 
533  $mockFormElement->_set('type', 'Text');
534  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
535  $mockFormElement->_set('identifier', $formElementIdentifier);
536  $mockFormElement->_set('label', 'some label');
537 
538  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
539  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
540  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
541 
542  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
543  }
544 
549  {
550  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
551  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
552 
553  $formRuntimeIdentifier = 'form-runtime-identifier';
554  $formElementIdentifier = 'form-element-identifier';
555 
556  $formRuntimeRenderingOptions = [
557  'translation' => [
558  'translationFile' => $formRuntimeXlfPath,
559  'translatePropertyValueIfEmpty' => true
560  ],
561  ];
562 
563  $formElementRenderingOptions = [
564  'translation' => [
565  'translationFile' => $textElementXlfPath,
566  'translatePropertyValueIfEmpty' => true
567  ],
568  ];
569  $formElementProperties = [
570  'placeholder' => 'placeholder',
571  ];
572 
573  $expected = 'form-element-identifier PLACEHOLDER EN';
574 
575  $this->store->flushData($formRuntimeXlfPath);
576  $this->store->flushData($textElementXlfPath);
577 
578  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
579 
580  $mockFormElement->_set('type', 'Text');
581  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
582  $mockFormElement->_set('identifier', $formElementIdentifier);
583  $mockFormElement->_set('properties', $formElementProperties);
584 
585  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
586  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
587  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
588 
589  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['placeholder'], $mockFormRuntime));
590  }
591 
596  {
597  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
598  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
599 
600  $formRuntimeIdentifier = 'another-form-runtime-identifier';
601  $formElementIdentifier = 'another-form-element-identifier';
602 
603  $formRuntimeRenderingOptions = [
604  'translation' => [
605  'translationFile' => $formRuntimeXlfPath,
606  'translatePropertyValueIfEmpty' => true
607  ],
608  ];
609 
610  $formElementRenderingOptions = [
611  'translation' => [
612  'translationFile' => $textElementXlfPath,
613  'translatePropertyValueIfEmpty' => true
614  ],
615  ];
616  $formElementProperties = [
617  'placeholder' => 'placeholder',
618  ];
619 
620  $expected = 'placeholder';
621 
622  $this->store->flushData($formRuntimeXlfPath);
623  $this->store->flushData($textElementXlfPath);
624 
625  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
626 
627  $mockFormElement->_set('type', 'Text');
628  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
629  $mockFormElement->_set('identifier', $formElementIdentifier);
630  $mockFormElement->_set('properties', $formElementProperties);
631 
632  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
633  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
634  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
635 
636  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['placeholder'], $mockFormRuntime));
637  }
638 
643  {
644  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
645  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
646 
647  $formRuntimeIdentifier = 'form-runtime-identifier';
648  $formElementIdentifier = 'form-element-identifier-page';
649 
650  $formRuntimeRenderingOptions = [
651  'translation' => [
652  'translationFile' => $formRuntimeXlfPath,
653  'translatePropertyValueIfEmpty' => true
654  ],
655  ];
656 
657  $formElementRenderingOptions = [
658  'nextButtonLabel' => 'next button label',
659  'translation' => [
660  'translationFile' => $textElementXlfPath,
661  'translatePropertyValueIfEmpty' => true
662  ],
663  ];
664  $formElementProperties = [
665  'placeholder' => 'placeholder',
666  ];
667 
668  $expected = 'form-element-identifier nextButtonLabel EN';
669 
670  $this->store->flushData($formRuntimeXlfPath);
671  $this->store->flushData($textElementXlfPath);
672 
673  $mockFormElement = $this->getAccessibleMock(Page::class, ['dummy'], [], '', false);
674 
675  $mockFormElement->_set('type', 'Page');
676  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
677  $mockFormElement->_set('identifier', $formElementIdentifier);
678  $mockFormElement->_set('properties', $formElementProperties);
679 
680  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
681  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
682  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
683 
684  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['nextButtonLabel'], $mockFormRuntime));
685  }
686 
691  {
692  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
693  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
694 
695  $formRuntimeIdentifier = 'form-runtime-identifier';
696  $formElementIdentifier = 'options-form-element-identifier';
697 
698  $formRuntimeRenderingOptions = [
699  'translation' => [
700  'translationFile' => $formRuntimeXlfPath,
701  'translatePropertyValueIfEmpty' => true
702  ],
703  ];
704 
705  $formElementRenderingOptions = [
706  'translation' => [
707  'translationFile' => $textElementXlfPath,
708  'translatePropertyValueIfEmpty' => true
709  ],
710  ];
711  $formElementProperties = [
712  'options' => [
713  'optionValue1' => 'optionLabel1',
714  'optionValue2' => 'optionLabel2'
715  ],
716  ];
717 
718  $expected = [
719  'optionValue1' => 'options-form-element-identifier option 1 EN',
720  'optionValue2' => 'options-form-element-identifier option 2 EN'
721  ];
722 
723  $this->store->flushData($formRuntimeXlfPath);
724  $this->store->flushData($textElementXlfPath);
725 
726  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
727 
728  $mockFormElement->_set('type', 'Text');
729  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
730  $mockFormElement->_set('identifier', $formElementIdentifier);
731  $mockFormElement->_set('properties', $formElementProperties);
732 
733  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
734  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
735  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
736 
737  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['options'], $mockFormRuntime));
738  }
739 
744  {
745  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
746  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
747 
748  $formRuntimeIdentifier = 'another-form-runtime-identifier';
749  $formElementIdentifier = 'options-form-element-identifier';
750 
751  $formRuntimeRenderingOptions = [
752  'translation' => [
753  'translationFile' => $formRuntimeXlfPath,
754  'translatePropertyValueIfEmpty' => true
755  ],
756  ];
757 
758  $formElementRenderingOptions = [
759  'translation' => [
760  'translationFile' => $textElementXlfPath,
761  'translatePropertyValueIfEmpty' => true
762  ],
763  ];
764  $formElementProperties = [
765  'options' => [
766  'optionValue1' => 'optionLabel1',
767  'optionValue2' => 'optionLabel2'
768  ],
769  ];
770 
771  $expected = [
772  'optionValue1' => 'options-form-element-identifier option 1 EN',
773  'optionValue2' => 'options-form-element-identifier option 2 EN'
774  ];
775 
776  $this->store->flushData($formRuntimeXlfPath);
777  $this->store->flushData($textElementXlfPath);
778 
779  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
780 
781  $mockFormElement->_set('type', 'Text');
782  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
783  $mockFormElement->_set('identifier', $formElementIdentifier);
784  $mockFormElement->_set('properties', $formElementProperties);
785 
786  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
787  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
788  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
789 
790  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['options'], $mockFormRuntime));
791  }
792 
797  {
798  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
799  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
800 
801  $formRuntimeIdentifier = 'form-runtime-identifier';
802  $finisherIdentifier = 'SaveToDatabaseFinisher';
803 
804  $formRuntimeRenderingOptions = [
805  'translation' => [
806  'translationFile' => $formRuntimeXlfPath,
807  'translatePropertyValueIfEmpty' => true
808  ],
809  ];
810 
811  $finisherRenderingOptions = [
812  'translationFile' => $textElementXlfPath,
813  'translatePropertyValueIfEmpty' => true
814  ];
815 
816  $expected = 'form-element-identifier SaveToDatabase subject EN';
817 
818  $this->store->flushData($formRuntimeXlfPath);
819  $this->store->flushData($textElementXlfPath);
820 
821  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
822  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
823  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
824 
825  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFinisherOption', $mockFormRuntime, $finisherIdentifier, 'subject', 'subject value', $finisherRenderingOptions));
826  }
827 
832  {
833  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
834  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
835 
836  $formRuntimeIdentifier = 'another-form-runtime-identifier';
837  $finisherIdentifier = 'SaveToDatabaseFinisher';
838 
839  $formRuntimeRenderingOptions = [
840  'translation' => [
841  'translationFile' => $formRuntimeXlfPath,
842  'translatePropertyValueIfEmpty' => true
843  ],
844  ];
845 
846  $finisherRenderingOptions = [
847  'translationFile' => $textElementXlfPath,
848  'translatePropertyValueIfEmpty' => true
849  ];
850 
851  $expected = 'form-element-identifier SaveToDatabase subject EN 1';
852 
853  $this->store->flushData($formRuntimeXlfPath);
854  $this->store->flushData($textElementXlfPath);
855 
856  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
857  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
858  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
859 
860  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFinisherOption', $mockFormRuntime, $finisherIdentifier, 'subject', 'subject value', $finisherRenderingOptions));
861  }
862 
867  {
868  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
869  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
870 
871  $formRuntimeIdentifier = 'my-form-runtime-identifier';
872  $formElementIdentifier = 'my-form-element-identifier';
873 
874  $formRuntimeRenderingOptions = [
875  'translation' => [
876  'translationFile' => $formRuntimeXlfPath,
877  'translatePropertyValueIfEmpty' => true
878  ],
879  ];
880 
881  $formElementRenderingOptions = [];
882 
883  $expected = 'my-form-runtime-identifier my-form-element-identifier LABEL EN';
884 
885  $this->store->flushData($formRuntimeXlfPath);
886  $this->store->flushData($textElementXlfPath);
887 
888  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
889 
890  $mockFormElement->_set('type', 'Text');
891  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
892  $mockFormElement->_set('identifier', $formElementIdentifier);
893  $mockFormElement->_set('label', 'some label');
894 
895  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
896  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
897  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
898 
899  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
900  }
901 
906  {
907  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
908 
909  $this->store->flushData($formRuntimeXlfPath);
910 
912  $formRuntime = $this->prophesize(FormRuntime::class);
913  $formRuntime->getIdentifier()->willReturn('my-form-runtime-identifier');
914  $formRuntime->getRenderingOptions()->willReturn([
915  'translation' => [
916  'translationFile' => $formRuntimeXlfPath,
917  'translatePropertyValueIfEmpty' => true,
918  ],
919  ]);
920 
922  $element = $this->prophesize(RootRenderableInterface::class);
923  $element->getIdentifier()->willReturn('my-form-element-with-translation-arguments');
924  $element->getType()->willReturn(RootRenderableInterface::class);
925  $element->getLabel()->willReturn('See %s or %s');
926  $element->getRenderingOptions()->willReturn([
927  'translation' => [
928  'arguments' => [
929  'label' => [
930  'this',
931  'that',
932  ],
933  ],
934  ],
935  ]);
936 
937  $expected = 'See this or that';
938  $result = $this->mockTranslationService->_call('translateFormElementValue', $element->reveal(), ['label'], $formRuntime->reveal());
939 
940  $this->assertEquals($expected, $result);
941  }
942 
947  {
948  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
949  $textElementXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf';
950 
951  $formRuntimeIdentifier = 'my-form-runtime-identifier';
952  $finisherIdentifier = 'SaveToDatabaseFinisher';
953 
954  $formRuntimeRenderingOptions = [
955  'translation' => [
956  'translationFile' => $formRuntimeXlfPath,
957  'translatePropertyValueIfEmpty' => true
958  ],
959  ];
960 
961  $finisherRenderingOptions = [];
962 
963  $expected = 'my-form-runtime-identifier form-element-identifier SaveToDatabase subject EN';
964 
965  $this->store->flushData($formRuntimeXlfPath);
966  $this->store->flushData($textElementXlfPath);
967 
968  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
969  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
970  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
971 
972  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFinisherOption', $mockFormRuntime, $finisherIdentifier, 'subject', 'subject value', $finisherRenderingOptions));
973  }
974 
979  {
980  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
981 
982  $this->store->flushData($formRuntimeXlfPath);
983 
985  $formRuntime = $this->prophesize(FormRuntime::class);
986  $formRuntime->getIdentifier()->willReturn('my-form-runtime-identifier');
987  $formRuntime->getRenderingOptions()->willReturn([
988  'translation' => [
989  'translationFile' => $formRuntimeXlfPath,
990  'translatePropertyValueIfEmpty' => true,
991  ],
992  ]);
993  $renderingOptions = [
994  'arguments' => [
995  'subject' => [
996  'awesome',
997  ],
998  ],
999  ];
1000 
1001  $expected = 'My awesome subject';
1002  $result = $this->mockTranslationService->_call('translateFinisherOption', $formRuntime->reveal(), 'EmailToReceiverWithTranslationArguments', 'subject', 'My %s subject', $renderingOptions);
1003 
1004  $this->assertEquals($expected, $result);
1005  }
1011  {
1012  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_form.xlf';
1013  $textElementXlfPaths = [
1014  10 => 'EXT:form/Tests/Unit/Service/Fixtures/locallang_text.xlf',
1015  20 => 'EXT:form/Tests/Unit/Service/Fixtures/locallang_additional_text.xlf'
1016  ];
1017 
1018  $formRuntimeIdentifier = 'form-runtime-identifier';
1019  $formElementIdentifier = 'form-element-identifier';
1020 
1021  $formRuntimeRenderingOptions = [
1022  'translation' => [
1023  'translationFile' => $formRuntimeXlfPath,
1024  'translatePropertyValueIfEmpty' => true
1025  ],
1026  ];
1027 
1028  $formElementRenderingOptions = [
1029  'translation' => [
1030  'translationFile' => $textElementXlfPaths,
1031  'translatePropertyValueIfEmpty' => true
1032  ],
1033  ];
1034 
1035  $expected = 'form-element-identifier ADDITIONAL LABEL EN';
1036 
1037  $this->store->flushData($formRuntimeXlfPath);
1038 
1039  foreach ($textElementXlfPaths as $textElementXlfPath) {
1040  $this->store->flushData($textElementXlfPath);
1041  }
1042 
1043  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
1044 
1045  $mockFormElement->_set('type', 'Text');
1046  $mockFormElement->_set('renderingOptions', $formElementRenderingOptions);
1047  $mockFormElement->_set('identifier', $formElementIdentifier);
1048  $mockFormElement->_set('label', 'some label');
1049 
1050  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions'], [], '', false);
1051  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1052  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1053 
1054  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
1055  }
1061  {
1062  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_01.xlf';
1063 
1064  $formRuntimeIdentifier = 'form-runtime-identifier-42';
1065  $formElementIdentifier = 'form-element-identifier';
1066 
1067  $formRuntimeRenderingOptions = [
1068  'submitButtonLabel' => '',
1069  'translation' => [
1070  'translationFile' => $formRuntimeXlfPath,
1071  'translatePropertyValueIfEmpty' => true
1072  ],
1073  ];
1074 
1075  $this->store->flushData($formRuntimeXlfPath);
1076 
1077  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions', 'getType'], [], '', false);
1078 
1079  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1080  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1081  $mockFormRuntime->expects($this->any())->method('getType')->willReturn('Form');
1082 
1083  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
1084 
1085  $mockFormElement->_set('type', 'Text');
1086  $mockFormElement->_set('identifier', $formElementIdentifier);
1087  $mockFormElement->_set('label', '');
1088 
1089  $expected = 'form-runtime-identifier-42 submitButtonLabel EN';
1090  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormRuntime, ['submitButtonLabel'], $mockFormRuntime));
1091 
1092  $expected = 'form-runtime-identifier-42 form-element-identifierlabel EN';
1093  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
1094  }
1100  {
1101  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_02.xlf';
1102 
1103  $formRuntimeIdentifier = 'form-runtime-identifier-42';
1104  $formElementIdentifier = 'form-element-identifier';
1105 
1106  $formRuntimeRenderingOptions = [
1107  'submitButtonLabel' => '',
1108  '_originalIdentifier' => 'form-runtime-identifier',
1109  'translation' => [
1110  'translationFile' => $formRuntimeXlfPath,
1111  'translatePropertyValueIfEmpty' => true
1112  ],
1113  ];
1114 
1115  $this->store->flushData($formRuntimeXlfPath);
1116 
1117  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions', 'getType'], [], '', false);
1118 
1119  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1120  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1121  $mockFormRuntime->expects($this->any())->method('getType')->willReturn('Form');
1122 
1123  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
1124 
1125  $mockFormElement->_set('type', 'Text');
1126  $mockFormElement->_set('identifier', $formElementIdentifier);
1127  $mockFormElement->_set('label', '');
1128 
1129  $expected = 'form-runtime-identifier submitButtonLabel EN';
1130  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormRuntime, ['submitButtonLabel'], $mockFormRuntime));
1131 
1132  $expected = 'form-runtime-identifier form-element-identifierlabel EN';
1133  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementValue', $mockFormElement, ['label'], $mockFormRuntime));
1134  }
1140  {
1141  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_01.xlf';
1142 
1143  $formRuntimeIdentifier = 'form-runtime-identifier-42';
1144  $formElementIdentifier = 'form-element-identifier';
1145 
1146  $formRuntimeRenderingOptions = [
1147  'translation' => [
1148  'translationFile' => $formRuntimeXlfPath,
1149  'translatePropertyValueIfEmpty' => true
1150  ],
1151  ];
1152 
1153  $this->store->flushData($formRuntimeXlfPath);
1154 
1155  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions', 'getType', 'getProperties'], [], '', false);
1156 
1157  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1158  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1159  $mockFormRuntime->expects($this->any())->method('getType')->willReturn('Form');
1160  $mockFormRuntime->expects($this->any())->method('getProperties')->willReturn([]);
1161 
1162  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
1163 
1164  $mockFormElement->_set('type', 'Text');
1165  $mockFormElement->_set('identifier', $formElementIdentifier);
1166  $mockFormElement->_set('label', '');
1167  $mockFormElement->_set('properties', []);
1168 
1169  $expected = 'form-runtime-identifier-42 error 123 EN';
1170  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementError', $mockFormRuntime, 123, [], 'default value', $mockFormRuntime));
1171 
1172  $expected = 'form-runtime-identifier-42 form-element-identifier error 123 EN';
1173  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementError', $mockFormElement, 123, [], 'default value', $mockFormRuntime));
1174  }
1180  {
1181  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_02.xlf';
1182 
1183  $formRuntimeIdentifier = 'form-runtime-identifier-42';
1184  $formElementIdentifier = 'form-element-identifier';
1185 
1186  $formRuntimeRenderingOptions = [
1187  '_originalIdentifier' => 'form-runtime-identifier',
1188  'translation' => [
1189  'translationFile' => $formRuntimeXlfPath,
1190  'translatePropertyValueIfEmpty' => true
1191  ],
1192  ];
1193 
1194  $this->store->flushData($formRuntimeXlfPath);
1195 
1196  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions', 'getType', 'getProperties'], [], '', false);
1197 
1198  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1199  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1200  $mockFormRuntime->expects($this->any())->method('getType')->willReturn('Form');
1201  $mockFormRuntime->expects($this->any())->method('getProperties')->willReturn([]);
1202 
1203  $mockFormElement = $this->getAccessibleMock(GenericFormElement::class, ['dummy'], [], '', false);
1204 
1205  $mockFormElement->_set('type', 'Text');
1206  $mockFormElement->_set('identifier', $formElementIdentifier);
1207  $mockFormElement->_set('label', '');
1208  $mockFormElement->_set('properties', []);
1209 
1210  $expected = 'form-runtime-identifier error 123 EN';
1211  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementError', $mockFormRuntime, 123, [], 'default value', $mockFormRuntime));
1212 
1213  $expected = 'form-runtime-identifier form-element-identifier error 123 EN';
1214  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFormElementError', $mockFormElement, 123, [], 'default value', $mockFormRuntime));
1215  }
1221  {
1222  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_01.xlf';
1223 
1224  $formRuntimeIdentifier = 'form-runtime-identifier-42';
1225 
1226  $formRuntimeRenderingOptions = [
1227  'translation' => [
1228  'translationFile' => $formRuntimeXlfPath,
1229  'translatePropertyValueIfEmpty' => true
1230  ],
1231  ];
1232 
1233  $this->store->flushData($formRuntimeXlfPath);
1234 
1235  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions', 'getType', 'getProperties'], [], '', false);
1236 
1237  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1238  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1239  $mockFormRuntime->expects($this->any())->method('getType')->willReturn('Form');
1240  $mockFormRuntime->expects($this->any())->method('getProperties')->willReturn([]);
1241 
1242  $expected = 'form-runtime-identifier-42 FooFinisher test EN';
1243  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFinisherOption', $mockFormRuntime, 'Foo', 'test', 'value', []));
1244  }
1250  {
1251  $formRuntimeXlfPath = 'EXT:form/Tests/Unit/Service/Fixtures/locallang_ceuid_suffix_02.xlf';
1252 
1253  $formRuntimeIdentifier = 'form-runtime-identifier-42';
1254 
1255  $formRuntimeRenderingOptions = [
1256  '_originalIdentifier' => 'form-runtime-identifier',
1257  'translation' => [
1258  'translationFile' => $formRuntimeXlfPath,
1259  'translatePropertyValueIfEmpty' => true
1260  ],
1261  ];
1262 
1263  $this->store->flushData($formRuntimeXlfPath);
1264 
1265  $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, ['getIdentifier', 'getRenderingOptions', 'getType', 'getProperties'], [], '', false);
1266 
1267  $mockFormRuntime->expects($this->any())->method('getIdentifier')->willReturn($formRuntimeIdentifier);
1268  $mockFormRuntime->expects($this->any())->method('getRenderingOptions')->willReturn($formRuntimeRenderingOptions);
1269  $mockFormRuntime->expects($this->any())->method('getType')->willReturn('Form');
1270  $mockFormRuntime->expects($this->any())->method('getProperties')->willReturn([]);
1271 
1272  $expected = 'form-runtime-identifier FooFinisher test EN';
1273  $this->assertEquals($expected, $this->mockTranslationService->_call('translateFinisherOption', $mockFormRuntime, 'Foo', 'test', 'value', []));
1274  }
1275 }
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFinisherOptionTranslateOptionForConcreteFormIfFinisherTranslationOptionsContainsATranslationFileAndFinisherOptionIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFinisherOptionTranslateOptionForConcreteFormIfFinisherTranslationOptionsContainsATranslationFileAndFinisherOptionIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:792
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateLabelFromAdditionalTranslationForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateLabelFromAdditionalTranslationForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:1006
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueNotTranslateLabelForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsEmptyAndPropertyShouldNotBeTranslatedAndTranslationExists
‪translateFormElementValueNotTranslateLabelForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsEmptyAndPropertyShouldNotBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:412
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementErrorTranslateErrorFromFormWithContentElementUidIfFormContainsNoOriginalIdentifier
‪translateFormElementErrorTranslateErrorFromFormWithContentElementUidIfFormContainsNoOriginalIdentifier()
Definition: TranslationServiceTest.php:1135
‪TYPO3\CMS\Form\Service\TranslationService
Definition: TranslationService.php:43
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateLabelForConcreteFormElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateLabelForConcreteFormElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:456
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\supportsArgumentsForFinisherOptionTranslations
‪supportsArgumentsForFinisherOptionTranslations()
Definition: TranslationServiceTest.php:974
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsExistingDefaultLanguageKeyIfDefaultLanguageKeyIsRequestedAndExtFilePathIsGiven
‪translateReturnsExistingDefaultLanguageKeyIfDefaultLanguageKeyIsRequestedAndExtFilePathIsGiven()
Definition: TranslationServiceTest.php:253
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\setUp
‪setUp()
Definition: TranslationServiceTest.php:57
‪TYPO3\CMS\Core\Localization\LocalizationFactory
Definition: LocalizationFactory.php:25
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsExistingDefaultLanguageKeyIfDefaultLanguageKeyIsRequestedAndLLLExtFilePathIsGiven
‪translateReturnsExistingDefaultLanguageKeyIfDefaultLanguageKeyIsRequestedAndLLLExtFilePathIsGiven()
Definition: TranslationServiceTest.php:270
‪TYPO3\CMS\Form\Domain\Model\FormElements\GenericFormElement
Definition: GenericFormElement.php:26
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsExistingDefaultLanguageKeyIfFullLLLExtDefaultLanguageKeyIsRequested
‪translateReturnsExistingDefaultLanguageKeyIfFullLLLExtDefaultLanguageKeyIsRequested()
Definition: TranslationServiceTest.php:130
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsExistingLanguageKeyForLanguageIfExtPathLanguageKeyIsRequested
‪translateReturnsExistingLanguageKeyForLanguageIfExtPathLanguageKeyIsRequested()
Definition: TranslationServiceTest.php:198
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFinisherOptionTranslateOptionFromFormWithContentElementUidIfFormContainsOriginalIdentifier
‪translateFinisherOptionTranslateOptionFromFormWithContentElementUidIfFormContainsOriginalIdentifier()
Definition: TranslationServiceTest.php:1245
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\$mockConfigurationManager
‪ConfigurationManager $mockConfigurationManager
Definition: TranslationServiceTest.php:44
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementTranslateFormWithContentElementUidIfFormContainsNoOriginalIdentifier
‪translateFormElementTranslateFormWithContentElementUidIfFormContainsNoOriginalIdentifier()
Definition: TranslationServiceTest.php:1056
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslatePropertyForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementPropertyIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslatePropertyForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementPropertyIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:544
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateRenderingOptionForConcreteFormAndConcreteSectionElementIfElementRenderingOptionsContainsATranslationFileAndElementRenderingOptionIsNotEmptyAndRenderingOptionShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateRenderingOptionForConcreteFormAndConcreteSectionElementIfElementRenderingOptionsContainsATranslationFileAndElementRenderingOptionIsNotEmptyAndRenderingOptionShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:638
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementTranslateFormWithContentElementUidIfFormContainsOriginalIdentifier
‪translateFormElementTranslateFormWithContentElementUidIfFormContainsOriginalIdentifier()
Definition: TranslationServiceTest.php:1095
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsDefaultValueIfNonExistingDefaultLanguageKeyIsRequestedAndDefaultValueIsGiven
‪translateReturnsDefaultValueIfNonExistingDefaultLanguageKeyIsRequestedAndDefaultValueIsGiven()
Definition: TranslationServiceTest.php:179
‪TYPO3\CMS\Form\Domain\Model\FormElements\Page
Definition: Page.php:40
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateLabelForConcreteFormAndConcreteElementFromFormRumtimeTranslationFileIfElementRenderingOptionsContainsNoTranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateLabelForConcreteFormAndConcreteElementFromFormRumtimeTranslationFileIfElementRenderingOptionsContainsNoTranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:862
‪TYPO3\CMS\Core\Localization\LanguageStore
Definition: LanguageStore.php:26
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager
Definition: ConfigurationManager.php:25
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: TranslationServiceTest.php:40
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFinisherOptionTranslateOptionForConcreteFormFromFormRuntimeIfFinisherTranslationOptionsContainsNoTranslationFileAndFinisherOptionIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFinisherOptionTranslateOptionForConcreteFormFromFormRuntimeIfFinisherTranslationOptionsContainsNoTranslationFileAndFinisherOptionIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:942
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueNotTranslatePropertyForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementPropertyIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationNotExists
‪translateFormElementValueNotTranslatePropertyForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementPropertyIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationNotExists()
Definition: TranslationServiceTest.php:591
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface
Definition: RootRenderableInterface.php:27
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateOptionsPropertyForConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementOptionsPropertyIsAnArrayAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateOptionsPropertyForConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementOptionsPropertyIsAnArrayAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:739
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateLabelForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateLabelForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:324
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsExistingDefaultLanguageKeyIfFullExtDefaultLanguageKeyIsRequested
‪translateReturnsExistingDefaultLanguageKeyIfFullExtDefaultLanguageKeyIsRequested()
Definition: TranslationServiceTest.php:115
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\$store
‪LanguageStore $store
Definition: TranslationServiceTest.php:52
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsExistingDefaultLanguageKeyIfDefaultLanguageKeyIsRequestedAndDefaultValueIsGiven
‪translateReturnsExistingDefaultLanguageKeyIfDefaultLanguageKeyIsRequestedAndDefaultValueIsGiven()
Definition: TranslationServiceTest.php:145
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\$mockTranslationService
‪TranslationService $mockTranslationService
Definition: TranslationServiceTest.php:48
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementErrorTranslateErrorFromFormWithContentElementUidIfFormContainsOriginalIdentifier
‪translateFormElementErrorTranslateErrorFromFormWithContentElementUidIfFormContainsOriginalIdentifier()
Definition: TranslationServiceTest.php:1175
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\supportsArgumentsForFormElementValueTranslations
‪supportsArgumentsForFormElementValueTranslations()
Definition: TranslationServiceTest.php:901
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormSession.php:3
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFinisherOptionTranslateOptionFromFormWithContentElementUidIfFormContainsNoOriginalIdentifier
‪translateFinisherOptionTranslateOptionFromFormWithContentElementUidIfFormContainsNoOriginalIdentifier()
Definition: TranslationServiceTest.php:1216
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateOptionsPropertyForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementOptionsPropertyIsAnArrayAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateOptionsPropertyForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementOptionsPropertyIsAnArrayAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:686
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsEmptyStringIfNonExistingLanguageKeyForLanguageIsRequested
‪translateReturnsEmptyStringIfNonExistingLanguageKeyForLanguageIsRequested()
Definition: TranslationServiceTest.php:235
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateLabelForFormElementTypeIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateLabelForFormElementTypeIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:500
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsEmptyStringIfNonExistingDefaultLanguageKeyIsRequested
‪translateReturnsEmptyStringIfNonExistingDefaultLanguageKeyIsRequested()
Definition: TranslationServiceTest.php:164
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateValuesRecursiveTranslateRecursive
‪translateValuesRecursiveTranslateRecursive()
Definition: TranslationServiceTest.php:287
‪TYPO3\CMS\Form\Tests\Unit\Service
Definition: TranslationServiceTest.php:3
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFormElementValueTranslateLabelForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFormElementValueTranslateLabelForConcreteFormAndConcreteElementIfElementRenderingOptionsContainsATranslationFileAndElementLabelIsEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:368
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateReturnsDefaultValueIfNonExistingLanguageKeyForLanguageIsRequestedAndDefaultValueIsGiven
‪translateReturnsDefaultValueIfNonExistingLanguageKeyForLanguageIsRequestedAndDefaultValueIsGiven()
Definition: TranslationServiceTest.php:216
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest
Definition: TranslationServiceTest.php:37
‪TYPO3\CMS\Form\Tests\Unit\Service\TranslationServiceTest\translateFinisherOptionTranslateOptionIfFinisherTranslationOptionsContainsATranslationFileAndFinisherOptionIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists
‪translateFinisherOptionTranslateOptionIfFinisherTranslationOptionsContainsATranslationFileAndFinisherOptionIsNotEmptyAndPropertyShouldBeTranslatedAndTranslationExists()
Definition: TranslationServiceTest.php:827