Add unit tests
[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 'childs' => ['ul','url','img','b','i']
12 ],
13 'i' => [
14 'type' => BBCODE::TYPE_NOARG
15 //TODO: by default open tag = <KEY> and close tag = </KEY>
16 ],
17 'b' => [
18 'type' => BBCODE::TYPE_NOARG
19 ],
20 'ul' => [
21 'type' => BBCODE::TYPE_NOARG,
22 'childs' => [ 'li' ]
23 ],
24 'li' => [
25 'type' => BBCODE::TYPE_NOARG,
26 'parent' => 'ul',
27 'childs' => ['url','img','b','i']
28 ],
29 'url' => [
30 'type' => BBCODE::TYPE_OPTARG,
31 'open_tag' => '<a href="{PARAM}">',
32 'close_tag' => '</a>',
33 'default_arg' => '{CONTENT}',
34 'parent' => [ '', 'li', 'b', 'i' ]
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]