Completed
Push — master ( ecd5d7...f9662e )
by Julián
11:22
created

EnvironmentTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
rs 10
1
<?php
2
3
/*
4
 * janitor (http://juliangut.com/janitor).
5
 * Effortless maintenance management.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/janitor
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
namespace Janitor\Test\Watcher;
13
14
use Janitor\Watcher\Environment;
15
16
/**
17
 * Class EnvironmentTest.
18
 */
19
class EnvironmentTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var Environment
23
     */
24
    protected $watcher;
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public static function setUpBeforeClass()
30
    {
31
        putenv('JanitorMaintenance=On');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public static function tearDownAfterClass()
38
    {
39
        putenv('JanitorMaintenance');
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function setUp()
46
    {
47
        $this->watcher = new Environment('JanitorMaintenance');
48
    }
49
50
    public function testIsNotActive()
51
    {
52
        putenv('JanitorMaintenance=On');
53
54
        self::assertTrue($this->watcher->isActive());
55
56
        $this->watcher->addVariable('JanitorMaintenance', 'Off');
57
58
        self::assertFalse($this->watcher->isActive());
59
60
        putenv('JanitorMaintenance');
61
    }
62
63
    public function testIsActive()
64
    {
65
        self::assertFalse($this->watcher->isActive());
66
67
        putenv('JanitorMaintenance=On');
68
69
        $this->watcher->addVariable('JanitorMaintenance', 'On');
70
71
        self::assertTrue($this->watcher->isActive());
72
73
        putenv('JanitorMaintenance');
74
    }
75
}
76