Completed
Push — master ( 737868...ff5584 )
by Jeroen
06:38 queued 11s
created

KunstmaanAdminExtensionTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\AdminBundle\Tests\DependencyInjection;
4
5
use Kunstmaan\AdminBundle\DependencyInjection\KunstmaanAdminExtension;
6
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
7
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
8
9
/**
10
 * Class KunstmaanAdminExtensionTest
11
 */
12
class KunstmaanAdminExtensionTest extends AbstractExtensionTestCase
13
{
14
    /**
15
     * @return ExtensionInterface[]
0 ignored issues
show
Consider making the return type a bit more specific; maybe use KunstmaanAdminExtension[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
16
     */
17
    protected function getContainerExtensions()
18
    {
19
        return [new KunstmaanAdminExtension()];
20
    }
21
22
    public function testCorrectParametersHaveBeenSet()
23
    {
24
        $this->load([
25
            'dashboard_route' => true,
26
            'admin_password' => 'omgchangethis',
27
            'menu_items' => [
28
                [
29
                    'route' => 'route66',
30
                    'label' => 'Route 66',
31
                ],
32
            ],
33
        ]);
34
35
        $this->assertContainerBuilderHasParameter('version_checker.url', 'https://bundles.kunstmaan.be/version-check');
36
        $this->assertContainerBuilderHasParameter('version_checker.timeframe', (60 * 60 * 24));
37
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.admin_locales');
38
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.default_admin_locale');
39
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.session_security.ip_check');
40
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.session_security.user_agent_check');
41
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.google_signin.enabled');
42
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.google_signin.client_id');
43
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.google_signin.client_secret');
44
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.google_signin.hosted_domains');
45
    }
46
47
    public function testWebsiteTitleWithParameterSet()
48
    {
49
        $this->setParameter('websitetitle', 'Mywebsite');
50
51
        $this->load();
52
53
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.website_title', 'Mywebsite');
54
    }
55
56
    public function testWebsiteTitleWithParameterAndConfigSet()
57
    {
58
        $this->setParameter('websitetitle', 'Mywebsite');
59
60
        $this->load(['website_title' => 'My real website']);
61
62
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.website_title', 'My real website');
63
    }
64
65
    public function testMultiLanguageWithParameterSet()
66
    {
67
        $this->setParameter('multilanguage', true);
68
69
        $this->load();
70
71
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.multi_language', true);
72
    }
73
74 View Code Duplication
    public function testMultiLanguageWithParameterAndConfigSet()
75
    {
76
        $this->setParameter('multilanguage', false);
77
78
        $this->load(['multi_language' => true]);
79
80
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.multi_language', true);
81
    }
82
83
    /**
84
     * @group legacy
85
     */
86 View Code Duplication
    public function testMultiLanguageScalarParameter()
87
    {
88
        $this->setParameter('multilanguage', true);
89
90
        $this->load(['multi_language' => 'randomvalue']);
91
92
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.multi_language', true);
93
    }
94
95
    public function testRequiredLocalesWithParameterSet()
96
    {
97
        $this->setParameter('requiredlocales', 'nl|en');
98
99
        $this->load();
100
101
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.required_locales', 'nl|en');
102
    }
103
104
    public function testRequiredLocalesWithParameterAndConfigSet()
105
    {
106
        $this->setParameter('requiredlocales', 'nl|en');
107
108
        $this->load(['required_locales' => 'nl|en|fr']);
109
110
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.required_locales', 'nl|en|fr');
111
    }
112
113
    public function testDefaultLocaleWithParameterSet()
114
    {
115
        $this->setParameter('defaultlocale', 'en');
116
117
        $this->load();
118
119
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.default_locale', 'en');
120
    }
121
122
    public function testDefaultLocaleWithParameterAndConfigSet()
123
    {
124
        $this->setParameter('defaultlocale', 'en');
125
126
        $this->load(['default_locale' => 'nl']);
127
128
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.default_locale', 'nl');
129
    }
130
131
    /**
132
     * @group legacy
133
     * @expectedDeprecation Not providing a value for the "kunstmaan_admin.website_title" config is deprecated since KunstmaanAdminBundle 5.2, this config value will be required in KunstmaanAdminBundle 6.0.
134
     * @expectedDeprecation Not providing a value for the "kunstmaan_admin.multi_language" config is deprecated since KunstmaanAdminBundle 5.2, this config value will be required in KunstmaanAdminBundle 6.0.
135
     * @expectedDeprecation Not providing a value for the "kunstmaan_admin.required_locales" config is deprecated since KunstmaanAdminBundle 5.2, this config value will be required in KunstmaanAdminBundle 6.0.
136
     * @expectedDeprecation Not providing a value for the "kunstmaan_admin.default_locale" config is deprecated since KunstmaanAdminBundle 5.2, this config value will be required in KunstmaanAdminBundle 6.0.
137
     */
138
    public function testLegacyParameters()
139
    {
140
        $this->load();
141
142
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.website_title', '');
143
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.multi_language', '');
144
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.required_locales', '');
145
        $this->assertContainerBuilderHasParameter('kunstmaan_admin.default_locale', '');
146
    }
147
148
    protected function setUp()
149
    {
150
        parent::setUp();
151
152
        // Some parameters required for the admin extension
153
        $this->container->setParameter('kernel.logs_dir', '/somewhere/over/the/rainbow');
154
        $this->container->setParameter('kernel.environment', 'staging');
155
    }
156
}
157