Passed
Pull Request — 4 (#10150)
by Maxime
07:10
created

TestKernel::getIgnoreCILibraries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace SilverStripe\Dev;
4
5
use SilverStripe\Core\CoreKernel;
6
7
/**
8
 * Kernel for running unit tests
9
 */
10
class TestKernel extends CoreKernel
11
{
12
13
    /** @var string[] $ciLibs */
14
    private $ciLibs = [];
15
16
17
    public function __construct($basePath)
18
    {
19
        $this->setEnvironment(self::DEV);
20
        parent::__construct($basePath);
21
    }
22
23
    /**
24
     * Reset kernel between tests.
25
     * Note: this avoids resetting services (See TestState for service specific reset)
26
     *
27
     * @return $this
28
     */
29
    public function reset()
30
    {
31
        $this->setEnvironment(self::DEV);
32
        $this->bootPHP();
33
        return $this;
34
    }
35
36
    protected function bootPHP()
37
    {
38
        parent::bootPHP();
39
40
        // Set default timezone consistently to avoid NZ-specific dependencies
41
        date_default_timezone_set('UTC');
42
    }
43
44
    protected function getIncludeTests()
45
    {
46
        return true;
47
    }
48
49
50
    /**
51
     * @param string[] $ciLibs
52
     */
53
    public function setIgnoreCILibraries(array $ciLibs): self
54
    {
55
        $this->ciLibs = $ciLibs;
56
        return $this;
57
    }
58
59
    protected function getIgnoreCILibraries(): array
60
    {
61
        return $this->ciLibs;
62
    }
63
64
    protected function bootErrorHandling()
65
    {
66
        // Leave phpunit to capture errors
67
        restore_error_handler();
68
    }
69
}
70