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

OptionsTest::testOptionsFileRepresentsDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 7
nc 1
nop 0
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
}