ConfigurationProviderBootLoaderTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testBoot() 0 11 1
A dataProvider() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[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 Micro\Framework\Kernel\Test\Unit\Boot;
15
16
use Micro\Framework\Kernel\Boot\ConfigurationProviderBootLoader;
17
use Micro\Framework\Kernel\Configuration\DefaultApplicationConfiguration;
18
use Micro\Framework\Kernel\Configuration\DefaultApplicationConfigurationFactory;
19
use Micro\Framework\Kernel\Test\Unit\ConfigurableTestPlugin;
20
use PHPUnit\Framework\TestCase;
21
22
class ConfigurationProviderBootLoaderTest extends TestCase
23
{
24
    /**
25
     * @dataProvider dataProvider
26
     */
27
    public function testBoot(mixed $configuration)
28
    {
29
        $plugin = new ConfigurableTestPlugin();
30
        $bootLoader = new ConfigurationProviderBootLoader($configuration);
31
        $bootLoader->boot($plugin);
32
33
        $this->assertEquals('test', $plugin->getEnv());
34
        $this->assertEquals(['a', 'b', 'c', 'd'], $plugin->getList());
35
        $this->assertEquals(['a', 'b', 'c', 'd'], $plugin->getAlreadyList());
36
        $this->assertEquals(['a,b,c,d'], $plugin->getListWithoutSeparator());
37
        $this->assertEquals('OK', $plugin->getConfigRoutingKeyValue());
38
    }
39
40
    public function dataProvider(): array
41
    {
42
        $cfgArr = [
43
            'APP_ENV' => 'test',
44
            'ENV_LIST' => 'a,b,c,d',
45
            'CONFIG_TEST_VALUE' => 'OK',
46
        ];
47
48
        return [
49
            [$cfgArr],
50
            [new DefaultApplicationConfiguration($cfgArr)],
51
            [new DefaultApplicationConfigurationFactory($cfgArr)],
52
        ];
53
    }
54
}
55