|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the PHP Translation package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) PHP Translation team <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\Translation\MessageCatalogue; |
|
13
|
|
|
use Translation\Bundle\Catalogue\CatalogueFetcher; |
|
14
|
|
|
use Translation\Bundle\Model\Configuration; |
|
15
|
|
|
use Translation\Bundle\Tests\Functional\BaseTestCase; |
|
16
|
|
|
|
|
17
|
|
|
class CatalogueFetcherTest extends BaseTestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var CatalogueFetcher |
|
21
|
|
|
*/ |
|
22
|
|
|
private $catalogueFetcher; |
|
23
|
|
|
|
|
24
|
|
|
public static function setUpBeforeClass(): void |
|
25
|
|
|
{ |
|
26
|
|
|
parent::setUpBeforeClass(); |
|
27
|
|
|
|
|
28
|
|
|
\file_put_contents( |
|
29
|
|
|
__DIR__.'/../app/Resources/translations/messages.sv.xlf', |
|
30
|
|
|
<<<'XML' |
|
31
|
|
|
<?xml version="1.0" encoding="utf-8"?> |
|
32
|
|
|
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="fr-FR" trgLang="en-US"> |
|
33
|
|
|
<file id="messages.en_US"> |
|
34
|
|
|
<unit id="LCa0a2j"> |
|
35
|
|
|
<segment> |
|
36
|
|
|
<source>key0</source> |
|
37
|
|
|
<target>trans0</target> |
|
38
|
|
|
</segment> |
|
39
|
|
|
</unit> |
|
40
|
|
|
<unit id="LCa0a2b"> |
|
41
|
|
|
<segment> |
|
42
|
|
|
<source>key1</source> |
|
43
|
|
|
<target>trans1</target> |
|
44
|
|
|
</segment> |
|
45
|
|
|
</unit> |
|
46
|
|
|
</file> |
|
47
|
|
|
</xliff> |
|
48
|
|
|
|
|
49
|
|
|
XML |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testFetchCatalogue(): void |
|
54
|
|
|
{ |
|
55
|
|
|
$this->bootKernel(); |
|
56
|
|
|
|
|
57
|
|
|
$this->catalogueFetcher = $this->getContainer()->get(CatalogueFetcher::class); |
|
58
|
|
|
|
|
59
|
|
|
$data = self::getDefaultData(); |
|
60
|
|
|
$data['external_translations_dirs'] = [__DIR__.'/../app/Resources/translations/']; |
|
61
|
|
|
|
|
62
|
|
|
$conf = new Configuration($data); |
|
63
|
|
|
|
|
64
|
|
|
/** @var MessageCatalogue[] $catalogues */ |
|
65
|
|
|
$catalogues = $this->catalogueFetcher->getCatalogues($conf, ['sv']); |
|
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
$this->assertEquals('sv', $catalogues[0]->getLocale()); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public static function getDefaultData(): array |
|
71
|
|
|
{ |
|
72
|
|
|
return [ |
|
73
|
|
|
'name' => 'getName', |
|
74
|
|
|
'locales' => ['getLocales'], |
|
75
|
|
|
'project_root' => 'getProjectRoot', |
|
76
|
|
|
'output_dir' => 'getOutputDir', |
|
77
|
|
|
'dirs' => ['getDirs'], |
|
78
|
|
|
'excluded_dirs' => ['getExcludedDirs'], |
|
79
|
|
|
'excluded_names' => ['getExcludedNames'], |
|
80
|
|
|
'external_translations_dirs' => ['getExternalTranslationsDirs'], |
|
81
|
|
|
'output_format' => 'getOutputFormat', |
|
82
|
|
|
'blacklist_domains' => ['getBlacklistDomains'], |
|
83
|
|
|
'whitelist_domains' => ['getWhitelistDomains'], |
|
84
|
|
|
'xliff_version' => ['getXliffVersion'], |
|
85
|
|
|
]; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
protected function setUp(): void |
|
89
|
|
|
{ |
|
90
|
|
|
parent::setUp(); |
|
91
|
|
|
|
|
92
|
|
|
$this->kernel->addConfigFile(__DIR__.'/../app/config/normal_config.yaml'); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.