Switch to single|root|multi type
[bbcode] / tests / 003.phpt
1 --TEST--
2 Check for bbcode clone
3 --SKIPIF--
4 <?php if (!extension_loaded("bbcode")) print "skip"; ?>
5 --FILE--
6 <?php
7 $obj = new bbcode(
8 [
9 '' => [
10 'type' => BBCODE::TYPE_ROOT,
11 'child' => ['ul','url','img','b','i']
12 ],
13 'i' => [
14 'type' => BBCODE::TYPE_MULTI
15 //TODO: by default open tag = <KEY> and close tag = </KEY>
16 ],
17 'b' => [
18 'type' => BBCODE::TYPE_MULTI
19 ],
20 'ul' => [
21 'type' => BBCODE::TYPE_MULTI,
22 'child' => [ 'li' ]
23 ],
24 'li' => [
25 'type' => BBCODE::TYPE_MULTI,
26 'parent' => 'ul',
27 'child' => ['url','img','b','i']
28 ],
29 'url' => [
30 'type' => BBCODE::TYPE_MULTI,
31 'parent' => [ '', 'li', 'b', 'i', null, 'toto', 0, 42 ],
32 'open' => '<a href="{PARAM}">',
33 'close' => '</a>',
34 'default' => '{CONTENT}'
35 ]
36 ],
37 [
38 ':)' => '<img src="smiley.gif" alt=":)" />',
39 ':(' => '<img src="sad.gif" alt=":(" />',
40 ':D' => '<img src="happy.gif" alt=":D" />',
41 ':p' => '<img src="tong.gif" alt=":p" />',
42 ':|' => '<img src="special.gif" alt=":|" />',
43 ':6:' => '<img src="six.gif" alt=":6:" />',
44 ],
45 BBCODE::REMOVE_EMPTY
46 );
47 $cln = clone $obj;
48 echo $cln->parse('[ul][li][url=https://rapsys.eu]Rapsys[/url][/li][li][url=https://google.fr]Google[/url][/li][/ul]');
49 ?>
50 --EXPECT--
51 [ul][li][url=https://rapsys.eu]Rapsys[/url][/li][li][url=https://google.fr]Google[/url][/li][/ul]