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

GlobalsTestState   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4
lcom 2
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A tearDown() 0 4 1
A setUpOnce() 0 4 1
A tearDownOnce() 0 4 1
1
<?php
2
3
namespace SilverStripe\Dev\State;
4
5
use SilverStripe\Control\Director;
6
use SilverStripe\Core\Environment;
7
use SilverStripe\Dev\SapphireTest;
8
9
/**
10
 * Cleans up and reset global env vars between tests
11
 */
12
class GlobalsTestState implements TestState
13
{
14
    /**
15
     * Var backed up for the class
16
     * @var array
17
     */
18
    protected $staticVars = [];
19
20
    /**
21
     * Vars backed up for the test
22
     * @var array
23
     */
24
    protected $vars = [];
25
26
    public function setUp(SapphireTest $test)
27
    {
28
        $this->vars = Environment::getVariables();
29
    }
30
31
    public function tearDown(SapphireTest $test)
32
    {
33
        Environment::setVariables($this->vars);
34
    }
35
36
    public function setUpOnce($class)
37
    {
38
        $this->staticVars = Environment::getVariables();
39
    }
40
41
    public function tearDownOnce($class)
42
    {
43
        Environment::setVariables($this->staticVars);
44
    }
45
}
46