Completed
Branch feature/add-scrutinizer (27b569)
by Matthias
02:05
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
lcom 0
cbo 2
dl 0
loc 45
rs 10
c 2
b 0
f 2

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
14
class OptionsTest extends \PHPUnit_Framework_TestCase
15
{
16
17
18
    public function testOptionsAcceptPhpCoreExtensions()
19
    {
20
        $options = new Options([
21
            'php-core-extensions' => ['something']
22
        ]);
23
24
        $this->assertSame(['something'], $options->getPhpCoreExtensions());
25
    }
26
27
    public function testOptionsAcceptSymbolWhitelist()
28
    {
29
        $options = new Options([
30
            'symbol-whitelist' => ['foo', 'bar']
31
        ]);
32
33
        $this->assertSame(['foo', 'bar'], $options->getSymbolWhitelist());
34
    }
35
36
    public function testOptionsFileRepresentsDefaults()
37
    {
38
        $options = new Options();
39
40
        $optionsFromFile = new Options(
41
            json_decode(file_get_contents(
42
                __DIR__ . '/../../../data/config.dist.json'
43
            ), true)
44
        );
45
46
        $this->assertEquals($options, $optionsFromFile);
47
    }
48
49
    public function testThrowsExceptionForUnknownOptions()
50
    {
51
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
52
        $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...
53
            'foo-bar' => ['foo', 'bar']
54
        ]);
55
56
    }
57
58
}