11<?php
22namespace Thunder \Shortcode \Tests ;
33
4+ use PHPUnit \Framework \Attributes \DataProvider ;
45use Thunder \Shortcode \HandlerContainer \HandlerContainer ;
56use Thunder \Shortcode \Parser \RegularParser ;
67use Thunder \Shortcode \Parser \ParserInterface ;
@@ -23,6 +24,7 @@ final class ParserTest extends AbstractTestCase
2324 *
2425 * @dataProvider provideShortcodes
2526 */
27+ #[DataProvider('provideShortcodes ' )]
2628 public function testParser (ParserInterface $ parser , $ code , array $ expected )
2729 {
2830 $ this ->assertShortcodes ($ parser ->parse ($ code ), $ expected );
@@ -276,6 +278,26 @@ public function testIssue77()
276278 ));
277279 }
278280
281+ public function testIssue119 ()
282+ {
283+ $ cases = [
284+ '[a k="\"y"]inner[/a] ' => new ParsedShortcode (new Shortcode ('a ' , array ('k ' => '\"y ' ), 'inner ' , null ), '[a k="\"y"]inner[/a] ' , 0 ),
285+ '[a k=" \"y"]inner[/a] ' => new ParsedShortcode (new Shortcode ('a ' , array ('k ' => ' \"y ' ), 'inner ' , null ), '[a k=" \"y"]inner[/a] ' , 0 ),
286+ '[a k=" x\"y"]inner[/a] ' => new ParsedShortcode (new Shortcode ('a ' , array ('k ' => ' x\"y ' ), 'inner ' , null ), '[a k=" x\"y"]inner[/a] ' , 0 ),
287+ '[a k="x\"y"]inner[/a] ' => new ParsedShortcode (new Shortcode ('a ' , array ('k ' => 'x\"y ' ), 'inner ' , null ), '[a k="x\"y"]inner[/a] ' , 0 ),
288+ '[mention id=1 name="foo\"ff\""][/mention] ' => new ParsedShortcode (new Shortcode ('mention ' , array ('id ' => '1 ' , 'name ' => 'foo\"ff\" ' ), '' , null ), '[mention id=1 name="foo\"ff\""][/mention] ' , 0 ),
289+ ];
290+ $ parser = new RegularParser ();
291+ foreach ($ cases as $ input => $ expected ) {
292+ $ this ->assertShortcodes ($ parser ->parse ($ input ), [$ expected ]);
293+ }
294+
295+ $ this ->assertShortcodes ($ parser ->parse ('[a k="x\"y"]inner[/a] [mention id=1 name="foo\"ff\""][/mention] ' ), [
296+ new ParsedShortcode (new Shortcode ('a ' , array ('k ' => 'x\"y ' ), 'inner ' , null ), '[a k="x\"y"]inner[/a] ' , 0 ),
297+ new ParsedShortcode (new Shortcode ('mention ' , array ('id ' => '1 ' , 'name ' => 'foo\"ff\" ' ), '' , null ), '[mention id=1 name="foo\"ff\""][/mention] ' , 22 ),
298+ ]);
299+ }
300+
279301 public function testWordPress ()
280302 {
281303 $ parser = new WordpressParser ();
0 commit comments