@@ -19,23 +19,26 @@ final class ParserTest extends AbstractTestCase
1919 /**
2020 * @param ParserInterface $parser
2121 * @param string $code
22- * @param ParsedShortcode[] $tested
22+ * @param ParsedShortcode[] $expected
2323 *
2424 * @dataProvider provideShortcodes
2525 */
26- public function testParser (ParserInterface $ parser , $ code , array $ tested )
26+ public function testParser (ParserInterface $ parser , $ code , array $ expected )
2727 {
28- $ parsed = $ parser ->parse ($ code );
28+ $ this ->assertShortcodes ($ parser ->parse ($ code ), $ expected );
29+ }
2930
30- $ count = count ($ tested );
31- static ::assertCount ($ count , $ parsed , 'counts ' );
31+ private function assertShortcodes (array $ actual , array $ expected )
32+ {
33+ $ count = count ($ actual );
34+ static ::assertCount ($ count , $ expected , 'counts ' );
3235 for ($ i = 0 ; $ i < $ count ; $ i ++) {
33- static ::assertSame ($ tested [$ i ]->getName (), $ parsed [$ i ]->getName (), 'name ' );
34- static ::assertSame ($ tested [$ i ]->getParameters (), $ parsed [$ i ]->getParameters (), 'parameters ' );
35- static ::assertSame ($ tested [$ i ]->getContent (), $ parsed [$ i ]->getContent (), 'content ' );
36- static ::assertSame ($ tested [$ i ]->getText (), $ parsed [$ i ]->getText (), 'text ' );
37- static ::assertSame ($ tested [$ i ]->getOffset (), $ parsed [$ i ]->getOffset (), 'offset ' );
38- static ::assertSame ($ tested [$ i ]->getBbCode (), $ parsed [$ i ]->getBbCode (), 'bbCode ' );
36+ static ::assertSame ($ actual [$ i ]->getName (), $ expected [$ i ]->getName (), 'name ' );
37+ static ::assertSame ($ actual [$ i ]->getParameters (), $ expected [$ i ]->getParameters (), 'parameters ' );
38+ static ::assertSame ($ actual [$ i ]->getContent (), $ expected [$ i ]->getContent (), 'content ' );
39+ static ::assertSame ($ actual [$ i ]->getText (), $ expected [$ i ]->getText (), 'text ' );
40+ static ::assertSame ($ actual [$ i ]->getOffset (), $ expected [$ i ]->getOffset (), 'offset ' );
41+ static ::assertSame ($ actual [$ i ]->getBbCode (), $ expected [$ i ]->getBbCode (), 'bbCode ' );
3942 }
4043 }
4144
@@ -258,6 +261,21 @@ public function provideShortcodes()
258261 return $ result ;
259262 }
260263
264+ public function testIssue77 ()
265+ {
266+ $ parser = new RegularParser ();
267+
268+ $ this ->assertShortcodes ($ parser ->parse ('[a][x][/x][x k="v][/x][y]x[/y] ' ), array (
269+ new ParsedShortcode (new Shortcode ('a ' , array (), null , null ), '[a] ' , 0 ),
270+ new ParsedShortcode (new Shortcode ('x ' , array (), '' , null ), '[x][/x] ' , 3 ),
271+ new ParsedShortcode (new Shortcode ('y ' , array (), 'x ' , null ), '[y]x[/y] ' , 22 ),
272+ ));
273+
274+ $ this ->assertShortcodes ($ parser ->parse ('[a k="v][x][/x] ' ), array (
275+ new ParsedShortcode (new Shortcode ('x ' , array (), '' , null ), '[x][/x] ' , 8 ),
276+ ));
277+ }
278+
261279 public function testWordPress ()
262280 {
263281 $ parser = new WordpressParser ();
@@ -291,7 +309,7 @@ public function testWordPress()
291309
292310 public function testWordpressInvalidNamesException ()
293311 {
294- $ this ->expectException ('InvalidArgumentException ' );
312+ $ this ->willThrowException ('InvalidArgumentException ' );
295313 WordpressParser::createFromNames (array ('string ' , new \stdClass ()));
296314 }
297315
0 commit comments