‪TYPO3CMS  11.5
XliffParserTest.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\Unit\UnitTestCase;
22 
26 class ‪XliffParserTest extends UnitTestCase
27 {
32  public function ‪canParseXliff(string $languageKey, array $expectedLabels): void
33  {
34  $LOCAL_LANG = (new ‪XliffParser())->getParsedData(__DIR__ . '/Fixtures/locallang.xlf', $languageKey);
35  self::assertArrayHasKey($languageKey, $LOCAL_LANG, sprintf('%s key not found in $LOCAL_LANG', $languageKey));
36  foreach ($expectedLabels as $key => $expectedLabel) {
37  self::assertEquals($expectedLabel, $LOCAL_LANG[$languageKey][$key][0]['target']);
38  }
39  }
40 
41  public function ‪canParseXliffDataProvider(): \Generator
42  {
43  yield 'Can handle default' => [
44  'languageKey' => 'default',
45  'expectedLabels' => [
46  'label1' => 'This is label #1',
47  'label2' => 'This is label #2',
48  'label3' => 'This is label #3',
49  ],
50  ];
51  yield 'Can handle translation' => [
52  'languageKey' => 'fr',
53  'expectedLabels' => [
54  'label1' => 'Ceci est le libellé no. 1',
55  'label2' => 'Ceci est le libellé no. 2',
56  'label3' => 'Ceci est le libellé no. 3',
57  ],
58  ];
59  }
60 }
‪TYPO3\CMS\Core\Tests\Unit\Localization\Parser\XliffParserTest\canParseXliffDataProvider
‪canParseXliffDataProvider()
Definition: XliffParserTest.php:41
‪TYPO3\CMS\Core\Tests\Unit\Localization\Parser
Definition: XliffParserTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Localization\Parser\XliffParserTest
Definition: XliffParserTest.php:27
‪TYPO3\CMS\Core\Localization\Parser\XliffParser
Definition: XliffParser.php:23
‪TYPO3\CMS\Core\Tests\Unit\Localization\Parser\XliffParserTest\canParseXliff
‪canParseXliff(string $languageKey, array $expectedLabels)
Definition: XliffParserTest.php:32