EnvironmentTest.php ➔ putenv()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: polidog
5
 * Date: 2016/07/17
6
 */
7
8
namespace Polidog\LaravelBundle\Tests {
9
10
11
use Polidog\LaravelBundle\Environment;
12
    use Polidog\LaravelBundle\State;
13
14
    class EnvironmentTest extends \PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * @test
18
     * @dataProvider environments
19
     */
20
    public function putEnvironment($key, $value)
21
    {
22
        $env = new Environment([$key => $value]);
23
        $env->put();
24
        $this->assertTrue(State::has("{$key}={$value}"));
25
    }
26
27
28
    public function environments()
29
    {
30
        return [
31
            ['hoge' , 'fuga'],
32
            ['APP_DEBUG' , true],
33
        ];
34
    }
35
}
36
37
}
38
39
namespace Polidog\LaravelBundle {
40
41
    class State {
42
        private static $value;
43
44
        public static function set($value)
45
        {
46
            self::$value = $value;
47
        }
48
49
        public static function has($value)
50
        {
51
            return self::$value == $value;
52
        }
53
54
        public static function reset()
55
        {
56
            self::$value = null;
57
        }
58
    }
59
60
    function putenv($value) {
61
        State::set($value);
62
    }
63
}