1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\TranslationBundle\Tests\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
17
|
|
|
use Sonata\TranslationBundle\Checker\TranslatableChecker; |
18
|
|
|
use Sonata\TranslationBundle\DependencyInjection\SonataTranslationExtension; |
19
|
|
|
use Sonata\TranslationBundle\Filter\TranslationFieldFilter; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Oskar Stark <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class SonataTranslationExtensionTest extends AbstractExtensionTestCase |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* NEXT_MAJOR: remove this annotation and corresponding deprecation notice. |
28
|
|
|
* |
29
|
|
|
* @group legacy |
30
|
|
|
*/ |
31
|
|
|
public function testLoadTwigIntlExtension(): void |
32
|
|
|
{ |
33
|
|
|
$this->container->setParameter('kernel.bundles', []); |
34
|
|
|
$this->load([ |
35
|
|
|
'locale_switcher_show_country_flags' => false, |
36
|
|
|
]); |
37
|
|
|
|
38
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithTag( |
39
|
|
|
'sonata_translation.twig.intl_extension', |
40
|
|
|
'twig.extension' |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* NEXT_MAJOR: remove this annotation and corresponding deprecation notice. |
46
|
|
|
* |
47
|
|
|
* @group legacy |
48
|
|
|
*/ |
49
|
|
|
public function testLoadServiceDefinitionWhenSonataDoctrineORMAdminBundleBundleIsRegistered(): void |
50
|
|
|
{ |
51
|
|
|
$this->container->setParameter('kernel.bundles', ['SonataDoctrineORMAdminBundle' => 'whatever']); |
52
|
|
|
$this->load(); |
53
|
|
|
$this->assertContainerBuilderHasService( |
54
|
|
|
'sonata_translation.checker.translatable', |
55
|
|
|
TranslatableChecker::class |
56
|
|
|
); |
57
|
|
|
$this->assertContainerBuilderHasService( |
58
|
|
|
'sonata_translation.filter.type.translation_field', |
59
|
|
|
TranslationFieldFilter::class |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* NEXT_MAJOR: remove this annotation and corresponding deprecation notice. |
65
|
|
|
* |
66
|
|
|
* @group legacy |
67
|
|
|
*/ |
68
|
|
|
public function testLoadServiceDefinitionNoCheckerTranslatable(): void |
69
|
|
|
{ |
70
|
|
|
$this->container->setParameter('kernel.bundles', []); |
71
|
|
|
$this->load(); |
72
|
|
|
|
73
|
|
|
$this->assertContainerBuilderNotHasService('sonata_translation.checker.translatable'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
protected function getContainerExtensions(): array |
77
|
|
|
{ |
78
|
|
|
return [new SonataTranslationExtension()]; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|