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

GlobalsTestState::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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