PathTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php declare(strict_types=1);
  2. namespace Svg\Tests;
  3. use Exception;
  4. use PHPUnit\Framework\TestCase;
  5. use Svg\Document;
  6. use Svg\Surface\SurfaceCpdf;
  7. use Svg\Tag\Path;
  8. final class PathTest extends TestCase
  9. {
  10. public static function commandProvider(): array
  11. {
  12. return [
  13. 'parse a relative arc with the shorthand format' => [
  14. 'a12.083 12.083 0 01.665 6.479',
  15. [
  16. [
  17. 'a',
  18. '12.083',
  19. '12.083',
  20. '0',
  21. '0',
  22. '1',
  23. '.665',
  24. '6.479',
  25. ],
  26. ],
  27. ],
  28. 'parse an absolute arc with the shorthand format' => [
  29. 'A12.083 12.083 0 01.665 6.479',
  30. [
  31. [
  32. 'A',
  33. '12.083',
  34. '12.083',
  35. '0',
  36. '0',
  37. '1',
  38. '.665',
  39. '6.479',
  40. ],
  41. ],
  42. ],
  43. 'parse two relative arcs that occur in sequence' => [
  44. 'a2.43,2.43,0,0,1,.65-1.57,5.91,5.91,0,0,0,1-2.78',
  45. [
  46. [
  47. 'a',
  48. '2.43',
  49. '2.43',
  50. '0',
  51. '0',
  52. '1',
  53. '.65',
  54. '-1.57',
  55. ],
  56. [
  57. 'a',
  58. '5.91',
  59. '5.91',
  60. '0',
  61. '0',
  62. '0',
  63. '1',
  64. '-2.78',
  65. ],
  66. ],
  67. ],
  68. ];
  69. }
  70. /**
  71. * @dataProvider commandProvider
  72. * @param string $commandSequence
  73. * @param array $expected
  74. */
  75. public function testParseCommands(string $commandSequence, array $expected)
  76. {
  77. $result = Path::parse($commandSequence);
  78. $this->assertSame($expected, $result);
  79. }
  80. }