1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the TranslationCollectorPassTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler; |
10
|
|
|
|
11
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\TranslationCollectorPass; |
12
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; |
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
14
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
15
|
|
|
|
16
|
|
|
class TranslationCollectorPassTest extends AbstractCompilerPassTestCase |
17
|
|
|
{ |
18
|
|
|
protected function registerCompilerPass(ContainerBuilder $container) |
19
|
|
|
{ |
20
|
|
|
$container->addCompilerPass(new TranslationCollectorPass()); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testTranslationCollector(): void |
24
|
|
|
{ |
25
|
|
|
$this->setDefinition('translator.default', new Definition()); |
26
|
|
|
$this->setParameter('kernel.root_dir', __DIR__ . $this->normalizePath('/../Fixtures/vendor')); |
27
|
|
|
|
28
|
|
|
$this->compile(); |
29
|
|
|
|
30
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( |
31
|
|
|
'translator.default', |
32
|
|
|
'addResource', |
33
|
|
|
[ |
34
|
|
|
'xlf', |
35
|
|
|
__DIR__ . $this->normalizePath('/../Fixtures/vendor/../vendor/ezplatform-i18n/ezplatform-i18n-hi_in/ezpublish-kernel/messages.hi_IN.xlf'), |
36
|
|
|
'hi', |
37
|
|
|
'messages', |
38
|
|
|
] |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( |
42
|
|
|
'translator.default', |
43
|
|
|
'addResource', |
44
|
|
|
[ |
45
|
|
|
'xlf', |
46
|
|
|
__DIR__ . $this->normalizePath('/../Fixtures/vendor/../vendor/ezplatform-i18n/ezplatform-i18n-nb_no/ezpublish-kernel/messages.nb_NO.xlf'), |
47
|
|
|
'no', |
48
|
|
|
'messages', |
49
|
|
|
] |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
$this->assertContainerBuilderHasParameter('available_translations', ['hi', 'no']); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param $path |
57
|
|
|
* |
58
|
|
|
* @return mixed |
59
|
|
|
*/ |
60
|
|
|
private function normalizePath($path) |
61
|
|
|
{ |
62
|
|
|
return str_replace('/', DIRECTORY_SEPARATOR, $path); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|