Issues (1519)

tests/Inji/ConfigTest.php (2 issues)

1
<?php
2
3
use  Inji\Config;
0 ignored issues
show
There must be a single space after the USE keyword
Loading history...
4
5
class ConfigTest extends \PHPUnit\Framework\TestCase {
6
7
    public function testSystem() {
8
        $config = Config::system(true);
9
        $this->assertNotEmpty($config);
10
11
        $config = Config::system();
12
        $this->assertNotEmpty($config);
13
14
        $time = time();
15
16
        $config['test'] = $time;
17
        Config::save('system', $config);
18
19
        $config = Config::system(true);
20
        $this->assertEquals($time, $config['test']);
21
    }
22
23
    public function testCustom() {
24
        $temp = INJI_PROGRAM_DIR . DIRECTORY_SEPARATOR . 'testConf.php';
25
        $time = time();
26
27
        Config::save($temp, ['test' => $time]);
28
        $config = Config::custom($temp, true);
29
        $this->assertEquals(['test' => $time], $config);
30
31
        $config = Config::custom($temp);
32
        $this->assertEquals(["test" => $time], $config);
33
34
        $config = Config::custom('notExist');
35
        $this->assertEmpty($config);
36
    }
37
38
    public function testApp() {
39
        $time = time();
40
        Config::save('app', ['test' => $time]);
41
        $config = Config::app(false, true);
0 ignored issues
show
false of type false is incompatible with the type Inji\App expected by parameter $app of Inji\Config::app(). ( Ignorable by Annotation )

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

41
        $config = Config::app(/** @scrutinizer ignore-type */ false, true);
Loading history...
42
        $this->assertEquals(["test" => $time], $config);
43
44
        $config = Config::app();
45
        $this->assertEquals(["test" => $time], $config);
46
47
        $config = Config::app(new \Inji\App(['path' => 'notExits']));
48
        $this->assertEmpty($config);
49
    }
50
51
    public function testShare() {
52
        $time = time();
53
        Config::save('share', ['test' => $time]);
54
55
        $config = Config::share('', true);
56
        $this->assertEquals(["test" => $time], $config);
57
58
        $config = Config::share();
59
        $this->assertEquals(["test" => $time], $config);
60
61
        Config::save('share', ['test' => $time], 'TestModule');
62
63
        $config = Config::share('TestModule', true);
64
        $this->assertEquals(["test" => $time], $config);
65
66
        $config = Config::share('TestModule');
67
        $this->assertEquals(["test" => $time], $config);
68
69
        $config = Config::share('notExist');
70
        $this->assertEmpty($config);
71
    }
72
73
    public function testModule() {
74
        $time = time();
75
        Config::save('module', ['test' => $time], 'TestModule');
76
77
        $config = Config::module('TestModule', null, true);
78
        $this->assertEquals(["test" => $time], $config);
79
80
        $config = Config::module('TestModule');
81
        $this->assertEquals(["test" => $time], $config);
82
83
        $config = Config::module('notExist');
84
        $this->assertEmpty($config);
85
    }
86
}