PHPParserTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 9 1
A testException() 0 5 1
A testDump() 0 11 1
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\PHPParser;
7
8
class PHPParserTest extends TestCase
9
{
10
    public function testParse()
11
    {
12
        $parser = new PHPParser();
13
        $data = $parser->parse(__DIR__ . '/../Fixtures/config.php');
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 PHPParser())->parse(__DIR__ . '/../Fixtures/no_return_array.php');
24
    }
25
26
    public function testDump()
27
    {
28
        $parser = new PHPParser();
29
        $file = __DIR__ . '/../Tmp/php-dump.php';
30
        $this->assertTrue($parser->dump($file, [
31
            'foo' => 'bar'
32
        ]));
33
        $this->assertEquals([
34
            'foo' => 'bar'
35
        ], $parser->parse($file));
36
    }
37
}
38