Passed
Push — master ( 345c9b...faecaf )
by Michiel
20:58
created

EnvironmentTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 39
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testVariablesNull() 0 4 1
A testValidateWithoutKeyAndValueSetRaisesException() 0 4 1
A setUp() 0 3 1
A testVariablesObjectIsArrayObject() 0 4 1
A testValuesAgainstGetContent() 0 8 1
1
<?php
2
3
class EnvironmentTest extends \PHPUnit\Framework\TestCase
4
{
5
    private $environment;
6
7
    public function setUp(): void
8
    {
9
        $this->environment = new Environment;
10
    }
11
12
    public function testVariablesNull()
13
    {
14
        $count = $this->environment->getVariables();
15
        $this->assertNull($count);
16
    }
17
18
    public function testVariablesObjectIsArrayObject()
19
    {
20
        $variablesObj = $this->environment->getVariablesObject();
21
        $this->assertEquals("ArrayObject", get_class($variablesObj));
22
    }
23
24
    /**
25
     * @expectedException        BuildException
26
     * @expectedExceptionMessage key and value must be specified for environment variables.
27
     */
28
    public function testValidateWithoutKeyAndValueSetRaisesException()
29
    {
30
        $ev = new EnvVariable();
31
        $ev->validate();
32
    }
33
34
    public function testValuesAgainstGetContent()
35
    {
36
        $ev = new EnvVariable();
37
        $ev->setKey(" key ");
38
        $ev->setValue(" value ");
39
        $ev->validate();
40
        $content = $ev->getContent();
41
        $this->assertEquals("key=value", $content);
42
    }
43
}
44