Completed
Pull Request — master (#31)
by
unknown
01:44
created

JsonLoaderTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasErrorWithWrongPath() 0 5 1
A testHasErrorWithInvalidFile() 0 5 1
A testHasDataWithValidFile() 0 6 1
1
<?php
2
3
namespace ComposerRequireCheckerTest;
4
5
use ComposerRequireChecker\JsonLoader;
6
use PHPUnit\Framework\TestCase;
7
8
class JsonLoaderTest extends TestCase
9
{
10
11
    /**
12
     * @expectedException ComposerRequireChecker\Exception\NotReadableException
13
     */
14
    public function testHasErrorWithWrongPath()
15
    {
16
        $path = __DIR__ . '/wrong/path/non-existing-file.json';
17
        $loader = new JsonLoader($path);
0 ignored issues
show
Unused Code introduced by
$loader 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...
18
    }
19
20
    /**
21
     * @expectedException ComposerRequireChecker\Exception\InvalidJsonException
22
     */
23
    public function testHasErrorWithInvalidFile()
24
    {
25
        $path = __DIR__ . '/../fixtures/invalidJson';
26
        $loader = new JsonLoader($path);
0 ignored issues
show
Unused Code introduced by
$loader 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...
27
    }
28
29
    public function testHasDataWithValidFile()
30
    {
31
        $path = __DIR__ . '/../fixtures/validJson.json';
32
        $loader = new JsonLoader($path);
33
        $this->assertEquals($loader->getData(), ['foo' => 'bar']);
34
    }
35
36
}
37