JsonLoaderTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 3
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasErrorWithInvalidFile() 0 5 1
A testHasErrorWithWrongPath() 0 5 1
A testHasDataWithValidFile() 0 5 1
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
final class JsonLoaderTest extends TestCase
14
{
15
    public function testHasErrorWithWrongPath(): void
16
    {
17
        $path = __DIR__ . '/wrong/path/non-existing-file.json';
18
        $this->expectException(NotReadableException::class);
19
        new JsonLoader($path);
20
    }
21
22
    public function testHasErrorWithInvalidFile(): void
23
    {
24
        $path = __DIR__ . '/../fixtures/invalidJson';
25
        $this->expectException(InvalidJsonException::class);
26
        new JsonLoader($path);
27
    }
28
29
    public function testHasDataWithValidFile(): void
30
    {
31
        $path = __DIR__ . '/../fixtures/validJson.json';
32
        $loader = new JsonLoader($path);
33
        $this->assertEquals($loader->getData(), ['foo' => 'bar']);
34
    }
35
}
36