Passed
Push — main ( ddea62...53290d )
by Leo
02:46
created

testConfigCatProviderWillFailIfConfigIsNotSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace MetroMarkets\FFBundle\Tests;
4
5
use MetroMarkets\FFBundle\FeatureFlagService;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
8
9
class ConfigurationTest extends TestCase
10
{
11
    public function testServiceWiring()
12
    {
13
        $kernel = new TestingKernel();
14
        $kernel->boot();
15
16
        $container = $kernel->getContainer();
17
18
        /** @var FeatureFlagService $service */
19
        $service = $container->get(FeatureFlagService::class);
20
21
        $this->assertInstanceOf(FeatureFlagService::class, $service);
22
    }
23
24
    public function testConfigCatProviderWillFailIfConfigIsNotSet()
25
    {
26
        $this->expectException(InvalidConfigurationException::class);
27
        $this->expectExceptionMessage('Configcat config must be set when using provider:configcat');
28
29
        $kernel = new TestingKernel([
30
            'provider' => 'configcat',
31
        ]);
32
33
        $kernel->boot();
34
    }
35
36
    public function testConfigCatProviderWillFailIfSdkKeyIsNotSet()
37
    {
38
        $this->expectException(InvalidConfigurationException::class);
39
        $this->expectExceptionMessage('Configcat sdk_key must be set');
40
41
        $kernel = new TestingKernel([
42
            'provider' => 'configcat',
43
            'configcat' => [
44
            ],
45
        ]);
46
47
        $kernel->boot();
48
    }
49
50
    public function testConfigCatProviderWillSuccedWithCorrectConfig()
51
    {
52
        $kernel = new TestingKernel([
53
            'provider' => 'configcat',
54
            'configcat' => [
55
                'sdk_key' => 'key'
56
            ],
57
        ]);
58
59
        $kernel->boot();
60
61
        $container = $kernel->getContainer();
62
63
        /** @var FeatureFlagService $service */
64
        $service = $container->get(FeatureFlagService::class);
65
66
        $this->assertInstanceOf(FeatureFlagService::class, $service);
67
    }
68
}