Passed
Pull Request — master (#32)
by Dmitriy
12:39
created

ParamsConfigTest::yamlFilesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
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 9
rs 10
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
            [
49
                'callable parameter',
50
                new LiterallyCallback(function () {
51
                    return 'I am callable';
52
                }),
53
            ],
54
            [
55
                'static callable parameter',
56
                new LiterallyCallback(static function () {
57
                    return 'I am callable';
58
                }),
59
            ],
60
            ['object parameter', new stdClass()],
61
            /**
62
             * Test for subpackages parameters
63
             */
64
            ['first-vendor/first-package', true],
65
            ['first-vendor/second-package', true],
66
            ['first-dev-vendor/first-package', true],
67
            ['first-dev-vendor/second-package', true],
68
            ['second-vendor/first-package', true],
69
            ['second-vendor/second-package', true],
70
            ['second-dev-vendor/first-package', true],
71
            ['second-dev-vendor/second-package', true],
72
            ['constant_based_parameter', 'a constant value defined in config/constants.php'],
73
            ['constant_from_vendor', 'a constant value defined in first-dev-vendor/second-package'],
74
        ];
75
    }
76
77
    private function yamlFilesProvider(): array
78
    {
79
        return [
80
            [
81
                'parameters',
82
                [
83
                    'param1' => 'value1',
84
                    'param2' => true,
85
                    'param3' => [1, 'value2'],
86
                ],
87
            ],
88
        ];
89
    }
90
}
91