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