GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 749633...2fce5c )
by joseph
17:28 queued 14:47
created

ConfigTest::getParam()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Small;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Config;
6
use EdmondsCommerce\DoctrineStaticMeta\ConfigInterface;
7
use EdmondsCommerce\DoctrineStaticMeta\Exception\ConfigException;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class ConfigTest
12
 *
13
 * @package EdmondsCommerce\DoctrineStaticMeta\Small
14
 * @coversDefaultClass   \EdmondsCommerce\DoctrineStaticMeta\Config
15
 */
16
class ConfigTest extends TestCase
17
{
18
    public const SERVER = [
19
        ConfigInterface::PARAM_DB_USER => 'Value-' . ConfigInterface::PARAM_DB_USER,
20
        ConfigInterface::PARAM_DB_PASS => 'Value-' . ConfigInterface::PARAM_DB_PASS,
21
        ConfigInterface::PARAM_DB_HOST => 'Value-' . ConfigInterface::PARAM_DB_HOST,
22
        ConfigInterface::PARAM_DB_NAME => 'Value-' . ConfigInterface::PARAM_DB_NAME,
23
    ];
24
25
    /**
26
     * @test
27
     * @small
28
     * @covers ::__construct
29
     */
30
    public function itThrowsAnExceptionRequiredParamNotSet(): void
31
    {
32
        self::expectException(ConfigException::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        self::/** @scrutinizer ignore-call */ 
33
              expectException(ConfigException::class);
Loading history...
33
        new Config([]);
34
    }
35
36
    /**
37
     * @test
38
     * @small
39
     * @covers ::validateConfig
40
     */
41
    public function itThrowsAnExceptionIfParamIsIncorrectType(): void
42
    {
43
        self::expectException(ConfigException::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        self::/** @scrutinizer ignore-call */ 
44
              expectException(ConfigException::class);
Loading history...
44
        $server[ConfigInterface::PARAM_DB_USER] = true;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$server was never initialized. Although not strictly required by PHP, it is generally a good practice to add $server = array(); before regardless.
Loading history...
45
        new Config([$server]);
46
    }
47
48
    /**
49
     * @test
50
     * @small
51
     * @covers ::validateConfig
52
     */
53
    public function itCanHandleIntoToBoolConversion(): void
54
    {
55
        $server                                  = self::SERVER;
56
        $server[ConfigInterface::PARAM_DEVMODE]  = 0;
57
        $server[ConfigInterface::PARAM_DB_DEBUG] = 1;
58
        $config                                  = new Config($server);
59
        self::assertFalse($config->get(ConfigInterface::PARAM_DEVMODE));
60
        self::assertTrue($config->get(ConfigInterface::PARAM_DB_DEBUG));
61
    }
62
63
    /**
64
     * @test
65
     * @small
66
     * @covers ::get
67
     */
68
    public function getParam(): void
69
    {
70
        $config   = new Config(self::SERVER);
71
        $expected = self::SERVER[ConfigInterface::PARAM_DB_NAME];
72
        $actual   = $config->get(ConfigInterface::PARAM_DB_NAME);
73
        self::assertSame($expected, $actual);
74
    }
75
76
    /**
77
     * @test
78
     * @small
79
     * @covers ::get
80
     */
81
    public function getDefaultParam(): void
82
    {
83
        $config   = new Config(self::SERVER);
84
        $expected = ConfigInterface::OPTIONAL_PARAMS_WITH_DEFAULTS[ConfigInterface::PARAM_DB_DEBUG];
85
        $actual   = $config->get(ConfigInterface::PARAM_DB_DEBUG);
86
        self::assertSame($expected, $actual);
87
    }
88
89
    /**
90
     * @test
91
     * @small
92
     * @covers ::getProjectRootDirectory
93
     */
94
    public function getProjectRootDirectory(): void
95
    {
96
        $config   = new Config(self::SERVER);
97
        $expected = realpath(__DIR__ . '/../../');
98
        $actual   = $config::getProjectRootDirectory();
99
        self::assertSame($expected, $actual);
100
    }
101
102
    /**
103
     * @test
104
     * @small
105
     * @covers ::calculateEntitiesPath
106
     * @covers ::get
107
     */
108
    public function getCalculatedDefaultParam(): void
109
    {
110
        $config   = new Config(self::SERVER);
111
        $expected = realpath(__DIR__ . '/../../') . '/src/Entities';
112
        $actual   = $config->get(ConfigInterface::PARAM_ENTITIES_PATH);
113
        self::assertSame($expected, $actual);
114
    }
115
116
    /**
117
     * @test
118
     * @small
119
     * @covers ::get
120
     */
121
    public function getConfiguredNotDefaultParam(): void
122
    {
123
        $server                                       = self::SERVER;
124
        $server[ConfigInterface::PARAM_ENTITIES_PATH] = realpath(__DIR__ . '/../../') . '/var/src/Entities';
125
        $config                                       = new Config($server);
126
        $expected                                     = $server[ConfigInterface::PARAM_ENTITIES_PATH];
127
        $actual                                       = $config->get(ConfigInterface::PARAM_ENTITIES_PATH);
128
        self::assertSame($expected, $actual);
129
    }
130
131
    /**
132
     * @test
133
     * @small
134
     * @coversNothing
135
     */
136
    public function paramsContainsAll(): void
137
    {
138
        $countParams     = count(ConfigInterface::PARAMS);
139
        $aggregated      = array_merge(
140
            ConfigInterface::REQUIRED_PARAMS,
141
            ConfigInterface::OPTIONAL_PARAMS_WITH_CALCULATED_DEFAULTS,
142
            ConfigInterface::OPTIONAL_PARAMS_WITH_DEFAULTS
143
        );
144
        $countAggregated = count($aggregated);
145
        self::assertSame($countAggregated, $countParams);
146
    }
147
}
148