Passed
Pull Request — master (#32)
by Dmitriy
71:48 queued 56:42
created

ParamsConfigTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 51
c 5
b 0
f 0
dl 0
loc 83
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultConfigName() 0 3 1
A phpFilesProvider() 0 56 1
A yamlFilesProvider() 0 9 1
A configProvider() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Tests\Integration\Tests\Config;
6
7
use stdClass;
8
use Yiisoft\Composer\Config\Tests\Integration\Tests\Helper\LiterallyCallback;
9
10
final class ParamsConfigTest extends ConfigTest
11
{
12
    public function configProvider(): array
13
    {
14
        return [
15
            ...$this->phpFilesProvider(),
16
            ...$this->yamlFilesProvider(),
17
        ];
18
    }
19
20
    protected function getDefaultConfigName(): string
21
    {
22
        return 'params';
23
    }
24
25
    private function phpFilesProvider(): array
26
    {
27
        return [
28
            ['boolean parameter', true],
29
            ['string parameter', 'value of param 1'],
30
            ['NAN parameter', 'NAN'],
31
            ['float parameter', 1.0000001],
32
            ['int parameter', 123],
33
            ['long int parameter', 123_000],
0 ignored issues
show
Bug introduced by
The constant Yiisoft\Composer\Config\...on\Tests\Config\123_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
            ['array parameter', [
35
                'changed value' => 'from root config',
36
                'first-vendor/first-package' => true,
37
                'first-vendor/second-package' => true,
38
                'second-vendor/first-package' => true,
39
                'second-vendor/second-package' => true,
40
                [[[[[]]]]],
41
            ]],
42
            ['array parameter with UnsetArrayValue', [
43
                'first-vendor/second-package' => true,
44
                'second-vendor/first-package' => true,
45
                'second-vendor/second-package' => true,
46
            ]],
47
            ['array parameter with ReplaceArrayValue', ['replace']],
48
            ['array parameter with RemoveArrayKeys', [
49
                'first-vendor/first-package',
50
                'first-vendor/second-package',
51
                'second-vendor/first-package',
52
                'second-vendor/second-package',
53
                'root value',
54
            ]],
55
            [
56
                'callable parameter',
57
                new LiterallyCallback(function () {
58
                    return 'I am callable';
59
                }),
60
            ],
61
            [
62
                'static callable parameter',
63
                new LiterallyCallback(static function () {
64
                    return 'I am callable';
65
                }),
66
            ],
67
            ['object parameter', new stdClass()],
68
            /**
69
             * Test for subpackages parameters
70
             */
71
            ['first-vendor/first-package', true],
72
            ['first-vendor/second-package', true],
73
            ['first-dev-vendor/first-package', true],
74
            ['first-dev-vendor/second-package', true],
75
            ['second-vendor/first-package', true],
76
            ['second-vendor/second-package', true],
77
            ['second-dev-vendor/first-package', true],
78
            ['second-dev-vendor/second-package', true],
79
            ['constant_based_parameter', 'a constant value defined in config/constants.php'],
80
            ['constant_from_vendor', 'a constant value defined in first-dev-vendor/second-package'],
81
        ];
82
    }
83
84
    private function yamlFilesProvider(): array
85
    {
86
        return [
87
            [
88
                'parameters',
89
                [
90
                    'param1' => 'value1',
91
                    'param2' => true,
92
                    'param3' => [1, 'value2'],
93
                ],
94
            ],
95
        ];
96
    }
97
}
98