Completed
Push — master ( b60ce0...53cbf4 )
by Matthias
02:13
created

OptionsTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 4
c 2
b 0
f 2
lcom 0
cbo 2
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testOptionsAcceptPhpCoreExtensions() 0 8 1
A testOptionsAcceptSymbolWhitelist() 0 8 1
A testOptionsFileRepresentsDefaults() 0 12 1
A testThrowsExceptionForUnknownOptions() 0 8 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: matthias
5
 * Date: 01.12.15
6
 * Time: 22:10
7
 */
8
9
namespace ComposerRequireCheckerTest\Cli;
10
11
12
use ComposerRequireChecker\Cli\Options;
13
use PHPUnit\Framework\TestCase;
14
15
class OptionsTest extends TestCase
16
{
17
18
19
    public function testOptionsAcceptPhpCoreExtensions()
20
    {
21
        $options = new Options([
22
            'php-core-extensions' => ['something']
23
        ]);
24
25
        $this->assertSame(['something'], $options->getPhpCoreExtensions());
26
    }
27
28
    public function testOptionsAcceptSymbolWhitelist()
29
    {
30
        $options = new Options([
31
            'symbol-whitelist' => ['foo', 'bar']
32
        ]);
33
34
        $this->assertSame(['foo', 'bar'], $options->getSymbolWhitelist());
35
    }
36
37
    public function testOptionsFileRepresentsDefaults()
38
    {
39
        $options = new Options();
40
41
        $optionsFromFile = new Options(
42
            json_decode(file_get_contents(
43
                __DIR__ . '/../../../data/config.dist.json'
44
            ), true)
45
        );
46
47
        $this->assertEquals($options, $optionsFromFile);
48
    }
49
50
    public function testThrowsExceptionForUnknownOptions()
51
    {
52
        $this->expectException('InvalidArgumentException');
53
        $options = new Options([
0 ignored issues
show
Unused Code introduced by
$options 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...
54
            'foo-bar' => ['foo', 'bar']
55
        ]);
56
57
    }
58
59
}