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
|
|
|
} |