Skip to content

Commit 771fd36

Browse files
committed
adding a bbcode test suite
git-svn-id: file:///svn/phpbb/trunk@8541 89ea8834-ac86-4346-8a33-228a782c2dd0
1 parent b1915b6 commit 771fd36

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

tests/all_tests.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
require_once 'PHPUnit/Framework.php';
99
require_once 'PHPUnit/TextUI/TestRunner.php';
1010

11+
require_once 'bbcode/all_tests.php';
1112
require_once 'utf/all_tests.php';
1213

14+
PHPUnit_Util_Filter::addDirectoryToFilter('./');
15+
1316
class phpbb_all_tests
1417
{
1518
public static function main()
@@ -21,6 +24,7 @@ public static function suite()
2124
{
2225
$suite = new PHPUnit_Framework_TestSuite('phpBB');
2326

27+
$suite->addTest(phpbb_bbcode_all_tests::suite());
2428
$suite->addTest(phpbb_utf_all_tests::suite());
2529

2630
return $suite;

tests/bbcode/all_tests.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
define('IN_PHPBB', true);
3+
if (!defined('PHPUnit_MAIN_METHOD'))
4+
{
5+
define('PHPUnit_MAIN_METHOD', 'phpbb_bbcode_all_tests::main');
6+
}
7+
8+
require_once 'PHPUnit/Framework.php';
9+
require_once 'PHPUnit/TextUI/TestRunner.php';
10+
11+
require_once 'bbcode/parser_test.php';
12+
13+
class phpbb_bbcode_all_tests
14+
{
15+
public static function main()
16+
{
17+
PHPUnit_TextUI_TestRunner::run(self::suite());
18+
}
19+
20+
public static function suite()
21+
{
22+
$suite = new PHPUnit_Framework_TestSuite('phpBB Formatted Text / BBCode');
23+
24+
$suite->addTestSuite('phpbb_bbcode_parser_test');
25+
26+
return $suite;
27+
}
28+
}
29+
30+
if (PHPUnit_MAIN_METHOD == 'phpbb_bbcode_all_tests::main')
31+
{
32+
phpbb_bbcode_all_tests::main();
33+
}
34+
?>

tests/bbcode/parser_test.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
define('IN_PHPBB', true);
3+
4+
require_once 'PHPUnit/Framework.php';
5+
require_once '../phpBB/includes/bbcode/bbcode_parser_base.php';
6+
require_once '../phpBB/includes/bbcode/bbcode_parser.php';
7+
8+
class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase
9+
{
10+
public function test_both_passes()
11+
{
12+
$parser = new phpbb_bbcode_parser();
13+
14+
$result = $parser->first_pass('[i]Italic [u]underlined text[/u][/i]');
15+
$result = $parser->second_pass($result);
16+
17+
$expected = '<span style="font-style: italic">Italic <span style="text-decoration: underline">underlined text</span></span>';
18+
19+
$this->assertEquals($expected, $result, 'Simple nested BBCode first+second pass');
20+
}
21+
}
22+
?>

0 commit comments

Comments
 (0)