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

JsonLoaderTest::testHasErrorWithWrongPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace ComposerRequireCheckerTest;
4
5
use ComposerRequireChecker\JsonLoader;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @covers \ComposerRequireChecker\JsonLoader
10
 */
11
class JsonLoaderTest extends TestCase
12
{
13
14
    /**
15
     * @expectedException \ComposerRequireChecker\Exception\NotReadableException
16
     */
17
    public function testHasErrorWithWrongPath()
18
    {
19
        $path = __DIR__ . '/wrong/path/non-existing-file.json';
20
        $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...
21
    }
22
23
    /**
24
     * @expectedException \ComposerRequireChecker\Exception\InvalidJsonException
25
     */
26
    public function testHasErrorWithInvalidFile()
27
    {
28
        $path = __DIR__ . '/../fixtures/invalidJson';
29
        $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...
30
    }
31
32
    public function testHasDataWithValidFile()
33
    {
34
        $path = __DIR__ . '/../fixtures/validJson.json';
35
        $loader = new JsonLoader($path);
36
        $this->assertEquals($loader->getData(), ['foo' => 'bar']);
37
    }
38
39
}
40