File: PathTest.php

package info (click to toggle)
php-dompdf-svg-lib 0.5.0-3%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 640 kB
  • sloc: php: 6,769; xml: 17; makefile: 13
file content (85 lines) | stat: -rw-r--r-- 2,290 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php declare(strict_types=1);

namespace Svg\Tests;

use Exception;
use PHPUnit\Framework\TestCase;
use Svg\Document;
use Svg\Surface\SurfaceCpdf;
use Svg\Tag\Path;

final class PathTest extends TestCase
{
    public function commandProvider(): array
    {
        return [
            'parse a relative arc with the shorthand format' => [
                'a12.083 12.083 0 01.665 6.479',
                [
                    [
                        'a',
                        '12.083',
                        '12.083',
                        '0',
                        '0',
                        '1',
                        '.665',
                        '6.479',
                    ],
                ],
            ],
            'parse an absolute arc with the shorthand format' => [
                'A12.083 12.083 0 01.665 6.479',
                [
                    [
                        'A',
                        '12.083',
                        '12.083',
                        '0',
                        '0',
                        '1',
                        '.665',
                        '6.479',
                    ],
                ],
            ],
            'parse two relative arcs that occur in sequence' => [
                'a2.43,2.43,0,0,1,.65-1.57,5.91,5.91,0,0,0,1-2.78',
                [
                    [
                        'a',
                        '2.43',
                        '2.43',
                        '0',
                        '0',
                        '1',
                        '.65',
                        '-1.57',
                    ],
                    [
                        'a',
                        '5.91',
                        '5.91',
                        '0',
                        '0',
                        '0',
                        '1',
                        '-2.78',
                    ],
                ],
            ],
        ];
    }

    /**
     * @dataProvider commandProvider
     * @param string $commandSequence
     * @param array $expected
     */
    public function testParseCommands(string $commandSequence, array $expected)
    {
        $result = Path::parse($commandSequence);

        $this->assertSame($expected, $result);
    }
}