Completed
Pull Request — 2.x (#337)
by
unknown
01:17
created

testLoadTwigIntlExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\DependencyInjection\SonataTranslationExtension;
18
19
/**
20
 * @author Oskar Stark <[email protected]>
21
 */
22
final class SonataTranslationExtensionTest extends AbstractExtensionTestCase
23
{
24
    /**
25
     * NEXT_MAJOR: remove this annotation and corresponding deprecation notice.
26
     *
27
     * @group legacy
28
     */
29
    public function testLoadTwigIntlExtension(): void
30
    {
31
        $this->container->setParameter('kernel.bundles', []);
32
        $this->load([
33
            'locale_switcher_show_country_flags' => false,
34
        ]);
35
36
        $this->assertContainerBuilderHasServiceDefinitionWithTag(
37
            'sonata_translation.twig.intl_extension',
38
            'twig.extension'
39
        );
40
    }
41
42
    /**
43
     * NEXT_MAJOR: remove this annotation and corresponding deprecation notice.
44
     *
45
     * @group legacy
46
     */
47
    public function testLoadServiceDefinitionWhenSonataDoctrineORMAdminBundleBundleIsRegistered(): void
48
    {
49
        $this->container->setParameter('kernel.bundles', ['SonataDoctrineORMAdminBundle' => 'whatever']);
50
        $this->load();
51
        $this->assertContainerBuilderHasService(
52
            'sonata_translation.checker.translatable',
53
            'Sonata\TranslationBundle\Checker\TranslatableChecker'
54
        );
55
        $this->assertContainerBuilderHasService(
56
            'sonata_translation.filter.type.translation_field',
57
            'Sonata\TranslationBundle\Filter\TranslationFieldFilter'
58
        );
59
    }
60
61
    /**
62
     * NEXT_MAJOR: remove this annotation and corresponding deprecation notice.
63
     *
64
     * @group legacy
65
     */
66
    public function testLoadServiceDefinitionNoCheckerTranslatable(): void
67
    {
68
        $this->container->setParameter('kernel.bundles', []);
69
        $this->load();
70
71
        $this->assertContainerBuilderNotHasService('sonata_translation.checker.translatable');
72
    }
73
74
    protected function getContainerExtensions(): array
75
    {
76
        return [new SonataTranslationExtension()];
77
    }
78
}
79