EnvironmentSpec::its_a_configuration_driver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of slick/configuration
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace spec\Slick\Configuration\Driver;
11
12
use Slick\Configuration\ConfigurationInterface;
13
use Slick\Configuration\Driver\Environment;
14
use PhpSpec\ObjectBehavior;
15
16
/**
17
 * EnvironmentSpec specs
18
 *
19
 * @package spec\Slick\Configuration\Driver
20
 */
21
class EnvironmentSpec extends ObjectBehavior
22
{
23
24
    function its_a_configuration_driver()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
    {
26
        $this->shouldBeAnInstanceOf(ConfigurationInterface::class);
27
    }
28
29
    function it_is_initializable()
30
    {
31
        $this->shouldHaveType(Environment::class);
32
    }
33
34
    function it_reads_environment_values()
35
    {
36
        $this->get('testenv.mode')->shouldBe('develop,debug,coverage');
0 ignored issues
show
Bug introduced by
The method get() does not exist on spec\Slick\Configuration\Driver\EnvironmentSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $this->/** @scrutinizer ignore-call */ 
37
               get('testenv.mode')->shouldBe('develop,debug,coverage');
Loading history...
37
    }
38
39
    function it_returns_a_default_value_if_a_given_key_is_not_found()
40
    {
41
        $setting = $this->get('baz', true);
42
        $setting->shouldBeBoolean();
43
        $setting->shouldBe(true);
44
    }
45
46
    function it_retrieves_a_value_recursively_using_a_dot_notation()
47
    {
48
        putenv("FIRST_SECOND_THIRD=123");
49
        $this->get('first.second.third')->shouldBe("123");
50
    }
51
52
    function it_sets_a_value_under_a_given_key()
53
    {
54
        $this->set('other', 'value')->shouldBe($this->getWrappedObject());
0 ignored issues
show
Bug introduced by
The method set() does not exist on spec\Slick\Configuration\Driver\EnvironmentSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        $this->/** @scrutinizer ignore-call */ 
55
               set('other', 'value')->shouldBe($this->getWrappedObject());
Loading history...
55
        $this->get('other')->shouldBe('value');
56
    }
57
58
    function it_sets_a_value_recursively_using_a_dot_notation()
59
    {
60
        $this->set('value.under.deep', 'path')->shouldBe($this->getWrappedObject());
61
        $this->get('value.under.deep')->shouldBe('path');
62
    }
63
}
64