@@ -68,6 +68,58 @@ public function testConvertPathDataSupportsCubicQuadraticAndArcCommands(): void
6868 self ::assertStringContainsString ('14.000000 10.000000 c ' , $ result );
6969 }
7070
71+ public function testConvertPathDataSupportsSmoothCurveCommandsWithoutPreviousControlPoints (): void
72+ {
73+ $ parser = new SvgPathCommandParser ();
74+
75+ $ result = $ parser ->convertPathData (
76+ 'M 2 2 S 4 4 6 2 T 10 2 ' ,
77+ 0.0 ,
78+ 12.0 ,
79+ '/tmp/smooth.svg ' ,
80+ [1.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
81+ );
82+
83+ self ::assertStringContainsString ('2.000000 10.000000 m ' , $ result );
84+ self ::assertStringContainsString ('2.000000 10.000000 4.000000 8.000000 6.000000 10.000000 c ' , $ result );
85+ self ::assertStringContainsString ('6.000000 10.000000 7.333333 10.000000 10.000000 10.000000 c ' , $ result );
86+ }
87+
88+ public function testConvertPathDataSupportsRelativeCommandsScientificNotationAndRelativeArc (): void
89+ {
90+ $ parser = new SvgPathCommandParser ();
91+
92+ $ result = $ parser ->convertPathData (
93+ 'M 1e1 1e1 l -5 0 h 2 v -3 a 4 2 0 0 1 6 0 ' ,
94+ 0.0 ,
95+ 20.0 ,
96+ '/tmp/relative-arc.svg ' ,
97+ [1.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
98+ );
99+
100+ self ::assertStringContainsString ('10.000000 10.000000 m ' , $ result );
101+ self ::assertStringContainsString ('5.000000 10.000000 l ' , $ result );
102+ self ::assertStringContainsString ('7.000000 10.000000 l ' , $ result );
103+ self ::assertStringContainsString ('7.000000 13.000000 l ' , $ result );
104+ self ::assertGreaterThanOrEqual (2 , substr_count ($ result , ' c ' ));
105+ }
106+
107+ public function testConvertPathDataSupportsSmoothCubicReflectionAfterPreviousCubic (): void
108+ {
109+ $ parser = new SvgPathCommandParser ();
110+
111+ $ result = $ parser ->convertPathData (
112+ 'M 0 0 C 2 2 4 2 6 0 S 10 -2 12 0 ' ,
113+ 0.0 ,
114+ 10.0 ,
115+ '/tmp/smooth-cubic.svg ' ,
116+ [1.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
117+ );
118+
119+ self ::assertStringContainsString ('6.000000 10.000000 c ' , $ result );
120+ self ::assertStringContainsString ('8.000000 12.000000 10.000000 12.000000 12.000000 10.000000 c ' , $ result );
121+ }
122+
71123 #[DataProvider('provideInvalidPathScenarios ' )]
72124 public function testConvertPathDataRejectsInvalidSequences (string $ pathData , string $ expectedMessage ): void
73125 {
0 commit comments