JsonParserTest::testParse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
namespace Slince\Config\Tests\Parser;
3
4
use PHPUnit\Framework\TestCase;
5
use Slince\Config\Exception\ParseException;
6
use Slince\Config\Parser\JsonParser;
7
8
class JsonParserTest extends TestCase
9
{
10
11
    public function testParse()
12
    {
13
        $parser = new JsonParser();
14
        $data = $parser->parse(__DIR__ . '/../Fixtures/config.json');
15
        $this->assertEquals([
16
            'foo' => 'bar',
17
            'bar' => 'baz',
18
        ], $data);
19
    }
20
21
    public function testException()
22
    {
23
        $this->setExpectedException(ParseException::class);
24
        (new JsonParser())->parse(__DIR__ . '/../Fixtures/syntax_error_json_file.json');
25
    }
26
27
    public function testDump()
28
    {
29
        $parser = new JsonParser();
30
        $file = __DIR__ . '/../Tmp/json-dump.json';
31
        $this->assertTrue($parser->dump($file, [
32
           'foo' => 'bar'
33
        ]));
34
        $this->assertEquals([
35
           'foo' => 'bar'
36
        ], $parser->parse($file));
37
    }
38
}
39