]> Raphaƫl G. Git Repositories - bbcode/blob - tests/002.phpt
Add new cloning test
[bbcode] / tests / 002.phpt
1 --TEST--
2 Check for bbcode functions
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 echo $obj->parse('[ul][li][url=https://rapsys.eu]Rapsys[/url][/li][li][url=https://google.fr]Google[/url][/li][/ul]');
48 /*
49 you can add regression tests for your extension here
50
51 the output of your test code has to be equal to the
52 text in the --EXPECT-- section below for the tests
53 to pass, differences between the output and the
54 expected text are interpreted as failure
55
56 see php7/README.TESTING for further information on
57 writing regression tests
58 */
59 ?>
60 --EXPECT--
61 [ul][li][url=https://rapsys.eu]Rapsys[/url][/li][li][url=https://google.fr]Google[/url][/li][/ul]