YamlParserTest::testDump()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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