Passed
Push — master ( 00043b...1ebea5 )
by Alexander
02:34
created

ParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 40
rs 10
c 0
b 0
f 0
1
<?php
2
3
use CyberLine\SystemdState\Parser;
4
5
class ParserTest extends \PHPUnit\Framework\TestCase
6
{
7
    /**
8
     * Dataprovider for Parser
9
     * @return array
10
     */
11
    public function dpParseValueByContent()
12
    {
13
        $dateTime = \date_create_immutable_from_format('* Y-m-d H:i:s e', time());
14
15
        $testCases = [
16
            [['test', 'yes'], true],
17
            [['test', 'no'], false],
18
            [['test', '0'], 0],
19
            [['test', 'test'], 'test'],
20
            [['test', '0123'], '0123'],
21
            [['test', '1234'], 1234],
22
            [['test', '18446744073709551615'], '18446744073709551615'],
23
            [['Timestamp', (string)$dateTime], $dateTime],
24
            [['Environment', 'FOO=bar BAZ=foo'], ['FOO' => 'bar', 'BAZ' => 'foo']],
25
        ];
26
27
        // To cover codecoverage
28
        foreach (Parser::getArrayTypes() as $arrayType) {
29
            $testCases[] = [[$arrayType, 'test1 test2'], ['test1', 'test2']];
30
        }
31
32
        return $testCases;
33
    }
34
35
    /**
36
     * @dataProvider dpParseValueByContent
37
     * @param $data
38
     * @param $expected
39
     */
40
    public function testParseValueByContent($data, $expected)
41
    {
42
        $this->assertEquals($expected, Parser::parseValueByContent($data));
43
    }
44
}
45