ValuePathParserTest::testInvalidPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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