Completed
Push — master ( 4ad6bd...3873e4 )
by Ingo
11:53
created

TestKernel   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A reset() 0 6 1
A bootPHP() 0 7 1
A getIncludeTests() 0 4 1
A bootErrorHandling() 0 5 1
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
    public function __construct($basePath)
13
    {
14
        $this->setEnvironment(self::DEV);
15
        parent::__construct($basePath);
16
    }
17
18
    /**
19
     * Reset kernel between tests.
20
     * Note: this avoids resetting services (See TestState for service specific reset)
21
     *
22
     * @return $this
23
     */
24
    public function reset()
25
    {
26
        $this->setEnvironment(self::DEV);
27
        $this->bootPHP();
28
        return $this;
29
    }
30
31
    protected function bootPHP()
32
    {
33
        parent::bootPHP();
34
35
        // Set default timezone consistently to avoid NZ-specific dependencies
36
        date_default_timezone_set('UTC');
37
    }
38
39
    protected function getIncludeTests()
40
    {
41
        return true;
42
    }
43
44
    protected function bootErrorHandling()
45
    {
46
        // Leave phpunit to capture errors
47
        restore_error_handler();
48
    }
49
}
50