‪TYPO3CMS  10.4
LanguageServiceTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪LanguageServiceTest extends FunctionalTestCase
24 {
28  protected ‪$subject;
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  $this->subject = ‪LanguageService::create('default');
34  }
35 
40  public function ‪splitLabelTest(string $input, string $expected): void
41  {
42  self::assertEquals($expected, $this->subject->sL($input));
43  }
44 
45  public function ‪splitLabelTestDataProvider(): \Generator
46  {
47  yield 'String without whitespace' => [
48  'Edit content',
49  'Edit content'
50  ];
51  yield 'String with leading whitespace' => [
52  ' Edit content',
53  ' Edit content'
54  ];
55  yield 'String with trailing whitespace' => [
56  'Edit content ',
57  'Edit content '
58  ];
59  yield 'String with outer whitespace' => [
60  ' Edit content ',
61  ' Edit content '
62  ];
63  yield 'String with inner whitespace' => [
64  'Edit content',
65  'Edit content'
66  ];
67  yield 'String with inner and outer whitespace' => [
68  ' Edit content ',
69  ' Edit content '
70  ];
71  yield 'String containing the LLL: key' => [
72  'You can use LLL: to ...',
73  'You can use LLL: to ...'
74  ];
75  yield 'String starting with the LLL: key' => [
76  'LLL: can be used to ...',
77  '' // @todo Should this special case be handled to return the input string?
78  ];
79  yield 'Locallang label without whitespace' => [
80  'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editcontent',
81  'Edit content'
82  ];
83  yield 'Locallang label with leading whitespace' => [
84  ' LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editcontent',
85  'Edit content'
86  ];
87  yield 'Locallang label with trailing whitespace' => [
88  'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editcontent ',
89  'Edit content'
90  ];
91  yield 'Locallang label with outer whitespace' => [
92  ' LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editcontent ',
93  'Edit content'
94  ];
95  yield 'Locallang label with inner whitespace' => [
96  'LLL: EXT: core/Resources/Private/Language/locallang_core.xlf:cm.editcontent',
97  'Edit content'
98  ];
99  yield 'Locallang label with inner and outer whitespace' => [
100  ' LLL: EXT: core/Resources/Private/Language/locallang_core.xlf:cm.editcontent ',
101  'Edit content'
102  ];
103  }
104 }
‪TYPO3\CMS\Core\Tests\Functional\Localization\LanguageServiceTest\splitLabelTestDataProvider
‪splitLabelTestDataProvider()
Definition: LanguageServiceTest.php:44
‪TYPO3\CMS\Core\Tests\Functional\Localization\LanguageServiceTest
Definition: LanguageServiceTest.php:24
‪TYPO3\CMS\Core\Tests\Functional\Localization\LanguageServiceTest\setUp
‪setUp()
Definition: LanguageServiceTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\Localization\LanguageServiceTest\$subject
‪LanguageService $subject
Definition: LanguageServiceTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\Localization\LanguageServiceTest\splitLabelTest
‪splitLabelTest(string $input, string $expected)
Definition: LanguageServiceTest.php:39
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Tests\Functional\Localization
Definition: LanguageServiceTest.php:18
‪TYPO3\CMS\Core\Localization\LanguageService\create
‪static static create(string $locale)
Definition: LanguageService.php:430