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
|
|
|
namespace Translation\Bundle\Tests\Unit\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
15
|
|
|
use Symfony\Component\Translation\DataCollector\TranslationDataCollector; |
16
|
|
|
use Translation\Bundle\DependencyInjection\TranslationExtension; |
17
|
|
|
use Translation\Bundle\EventListener\AutoAddMissingTranslations; |
18
|
|
|
use Translation\Bundle\EventListener\EditInPlaceResponseListener; |
19
|
|
|
use Translation\Bundle\Translator\FallbackTranslator; |
20
|
|
|
|
21
|
|
|
class TranslationExtensionTest extends AbstractExtensionTestCase |
22
|
|
|
{ |
23
|
|
|
protected function getContainerExtensions(): array |
24
|
|
|
{ |
25
|
|
|
$this->setParameter('kernel.default_locale', 'ar'); |
26
|
|
|
$this->setParameter('kernel.project_dir', __DIR__); |
27
|
|
|
$this->setParameter('kernel.debug', true); |
28
|
|
|
|
29
|
|
|
return [ |
30
|
|
|
new TranslationExtension(), |
31
|
|
|
]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testLocales(): void |
35
|
|
|
{ |
36
|
|
|
$locales = ['fr', 'sv']; |
37
|
|
|
$this->load(['locales' => $locales]); |
38
|
|
|
|
39
|
|
|
$this->assertContainerBuilderHasParameter('php_translation.locales', $locales); |
40
|
|
|
$this->assertContainerBuilderHasParameter('php_translation.default_locale', 'ar'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testDefaultLocales(): void |
44
|
|
|
{ |
45
|
|
|
$this->load(['default_locale' => 'sv']); |
46
|
|
|
|
47
|
|
|
$this->assertContainerBuilderHasParameter('php_translation.default_locale', 'sv'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testWebUiEnabled(): void |
51
|
|
|
{ |
52
|
|
|
$this->load(['webui' => ['enabled' => true]]); |
53
|
|
|
|
54
|
|
|
$this->assertContainerBuilderHasParameter('php_translation.webui.enabled', true); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testWebUiDisabled(): void |
58
|
|
|
{ |
59
|
|
|
$this->load(['webui' => ['enabled' => false]]); |
60
|
|
|
|
61
|
|
|
$this->assertContainerBuilderHasParameter('php_translation.webui.enabled', false); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testSymfonyProfilerEnabled(): void |
65
|
|
|
{ |
66
|
|
|
$this->load(['symfony_profiler' => ['enabled' => true]]); |
67
|
|
|
|
68
|
|
|
$this->assertContainerBuilderHasService('php_translation.data_collector', TranslationDataCollector::class); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testEditInPlaceEnabled(): void |
72
|
|
|
{ |
73
|
|
|
$this->load(['edit_in_place' => ['enabled' => true]]); |
74
|
|
|
|
75
|
|
|
$this->assertContainerBuilderHasService(EditInPlaceResponseListener::class); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testAutoAddEnabled(): void |
79
|
|
|
{ |
80
|
|
|
$this->load(['auto_add_missing_translations' => ['enabled' => true]]); |
81
|
|
|
|
82
|
|
|
$this->assertContainerBuilderHasService(AutoAddMissingTranslations::class); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function testFallbackTranslationEnabled(): void |
86
|
|
|
{ |
87
|
|
|
$this->load(['fallback_translation' => ['enabled' => true]]); |
88
|
|
|
|
89
|
|
|
$this->assertContainerBuilderHasService(FallbackTranslator::class); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|