Passed
Pull Request — master (#58)
by
unknown
03:15
created

EnvTypeCheckTest::testEnvSettingTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\EnvironmentCheck\Tests\Checks;
4
5
use SilverStripe\Core\Kernel;
6
use App\Checks\EnvSettingCheck;
0 ignored issues
show
Bug introduced by
The type App\Checks\EnvSettingCheck was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use SilverStripe\Control\Director;
8
use SilverStripe\Dev\SapphireTest;
9
use SilverStripe\Core\Injector\Injector;
10
use SilverStripe\EnvironmentCheck\EnvironmentCheck;
11
12
/**
13
 * Test the env setting check.
14
 */
15
class EnvTypeCheckTest extends SapphireTest
16
{
17
    /**
18
     * Check is OK when in live mode
19
     *
20
     * @return void
21
     */
22
    public function testEnvSettingLive()
23
    {
24
        /** @var Kernel $kernel */
25
        $kernel = Injector::inst()->get(Kernel::class);
26
        $kernel->setEnvironment('live');
27
28
        $this->assertTrue(Director::isLive());
29
30
        $checker = Injector::inst()->get(EnvSettingCheck::class);
31
        $result = $checker->check();
32
33
        $this->assertSame($result[0], EnvironmentCheck::OK);
34
    }
35
36
    /**
37
     * Check is ERROR when in test mode
38
     *
39
     * @return void
40
     */
41
    public function testEnvSettingTest()
42
    {
43
        /** @var Kernel $kernel */
44
        $kernel = Injector::inst()->get(Kernel::class);
45
        $kernel->setEnvironment('test');
46
47
        $this->assertTrue(Director::isTest());
48
49
        $checker = Injector::inst()->get(EnvSettingCheck::class);
50
        $result = $checker->check();
51
52
        $this->assertSame($result[0], EnvironmentCheck::ERROR);
53
    }
54
55
    /**
56
     * Check is ERROR when in dev mode
57
     *
58
     * @return void
59
     */
60
    public function testEnvSettingDev()
61
    {
62
        /** @var Kernel $kernel */
63
        $kernel = Injector::inst()->get(Kernel::class);
64
        $kernel->setEnvironment('dev');
65
66
        $this->assertTrue(Director::isDev());
67
68
        $checker = Injector::inst()->get(EnvSettingCheck::class);
69
        $result = $checker->check();
70
71
        $this->assertSame($result[0], EnvironmentCheck::ERROR);
72
    }
73
}
74