Passed
Push — master ( 2ce550...554c58 )
by Marcin
50s queued 10s
created

ConfigTest::testConstruct_1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by Marcin.
4
 * Date: 03.03.2019
5
 * Time: 16:52
6
 */
7
8
namespace Tests\Mrcnpdlk\Api\Unoconv;
9
10
use Mrcnpdlk\Api\Unoconv\Config;
11
use Mrcnpdlk\Api\Unoconv\Enum\DocType;
12
use Mrcnpdlk\Api\Unoconv\Enum\FormatType;
13
use Mrcnpdlk\Api\Unoconv\Exception\ConfigurationException;
14
use PHPUnit\Framework\TestCase;
15
16
class ConfigTest extends TestCase
17
{
18
    /**
19
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
20
     */
21
    public function testConstruct_1(): void
22
    {
23
        $oConfig = new Config();
0 ignored issues
show
Unused Code introduced by
$oConfig is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
24
        $this->assertTrue(true);
25
    }
26
27
    /**
28
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
29
     */
30
    public function testConstruct_2(): void
31
    {
32
        $oConfig = new Config([]);
0 ignored issues
show
Unused Code introduced by
$oConfig is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
33
        $this->assertTrue(true);
34
    }
35
36
    /**
37
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
38
     */
39
    public function testConstruct_3(): void
40
    {
41
        $oConfig = new Config([
42
            'binary'  => 'some_binary_file',
43
            'host'    => '127.0.0.1',
44
            'port'    => 2345,
45
            'docType' => DocType::GRAPHICS(),
46
            'format'  => FormatType::PDF(),
47
            'timeout' => 10,
48
        ]);
49
        $this->assertSame(DocType::GRAPHICS, $oConfig->getDocType()->getValue());
50
        $this->assertSame(FormatType::PDF, $oConfig->getFormat()->getValue());
51
        $this->assertSame(10, $oConfig->getTimeout());
52
    }
53
54
    /**
55
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
56
     */
57
    public function testConstruct_invalid(): void
58
    {
59
        $this->expectException(ConfigurationException::class);
60
        $oConfig = new Config([
0 ignored issues
show
Unused Code introduced by
$oConfig is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
61
            'foo_bar' => null,
62
        ]);
63
    }
64
}
65