Passed
Push — master ( dba989...50b90e )
by Mr
06:45
created

ValuePathParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
dl 0
loc 39
ccs 8
cts 9
cp 0.8889
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provideValuePathTestData() 0 14 1
A testTypePath() 0 6 1
A testInvalidPath() 0 4 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/entity project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Tests\Entity\Entity\Path;
10
11
use Daikon\Entity\Path\ValuePathParser;
12
use Daikon\Interop\InvalidArgumentException;
13
use PHPUnit\Framework\TestCase;
14
15
class ValuePathParserTest extends TestCase
16
{
17
    /**
18
     * @dataProvider provideValuePathTestData
19
     * @param string $pathExpression
20
     * @param int $expectedLength
21
     */
22 3
    public function testTypePath(string $pathExpression, int $expectedLength): void
23
    {
24 3
        $typePath = ValuePathParser::create()->parse($pathExpression);
25
26 3
        $this->assertCount($expectedLength, $typePath);
27 3
        $this->assertEquals($pathExpression, $typePath->__toString());
28 3
    }
29
30 1
    public function testInvalidPath(): void
31
    {
32 1
        $this->expectException(InvalidArgumentException::class);
33 1
        ValuePathParser::create()->parse('2-teasers');
34
    }
35
36
    /**
37
     * @codeCoverageIgnore
38
     * @return mixed[]
39
     */
40
    public function provideValuePathTestData(): array
41
    {
42
        return [
43
            [
44
                'pathExpression' => 'paragraphs',
45
                'expectedLength' => 1
46
            ],
47
            [
48
                'pathExpression' => 'paragraphs.1-title',
49
                'expectedLength' => 2
50
            ],
51
            [
52
                'pathExpression' => 'slideshows.2-teasers.3-images',
53
                'expectedLength' => 3
54
            ]
55
        ];
56
    }
57
}
58