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

JsonLoaderTest::testHasErrorWithInvalidFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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