From 754dc9c1592001ac4f223358fd708bd338f49fb3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 12:56:42 +0100 Subject: [PATCH 01/10] [ticket/11250] Add parsing tests for our basic bbcodes in simple cases PHPBB3-11250 --- tests/bbcode/parser_test.php | 148 +++++++++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 8 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 8c7fbc7128..697bcde610 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -13,17 +13,149 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase { - public function test_both_passes() + public function string_bbcode_data() { - $this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.'); - - $parser = new phpbb_bbcode_parser(); + return array( + // Default BBCodes from in their simplest way + array( + 'Test default bbcodes: simple bold', + '[b]bold[/b]', + '[b:]bold[/b:]', + ), + array( + 'Test default bbcodes: simple underlined', + '[u]underlined[/u]', + '[u:]underlined[/u:]', + ), + array( + 'Test default bbcodes: simple italic', + '[i]italic[/i]', + '[i:]italic[/i:]', + ), + array( + 'Test default bbcodes: simple color rgb', + '[color=#FF0000]colored[/color]', + '[color=#FF0000:]colored[/color:]', + ), + array( + 'Test default bbcodes: simple color name', + '[color=red]colored[/color]', + '[color=red:]colored[/color:]', + ), + array( + 'Test default bbcodes: simple quote', + '[quote]quoted[/quote]', + '[quote:]quoted[/quote:]', + ), + array( + 'Test default bbcodes: simple quote with username', + '[quote="username"]quoted[/quote]', + '[quote="username":]quoted[/quote:]', + ), + array( + 'Test default bbcodes: simple code', + '[code]unparsed code[/code]', + '[code:]unparsed code[/code:]', + ), + array( + 'Test default bbcodes: simple php code', + '[code=php]unparsed code[/code]', + '[code=php:]unparsed code[/code:]', + ), + array( + 'Test default bbcodes: simple list', + '[list]no item[/list]', + '[list:]no item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item only', + '[*]unparsed', + '[*]unparsed', + ), + array( + 'Test default bbcodes: simple list-item', + '[list][*]item[/list]', + '[list:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item closed', + '[list][*]item[/*][/list]', + '[list:][*:]item[/*:][/list:]', + ), + array( + 'Test default bbcodes: simple list-item numbered', + '[list=1][*]item[/list]', + '[list=1:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item alpha', + '[list=a][*]item[/list]', + '[list=a:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item roman', + '[list=i][*]item[/list]', + '[list=i:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item disc', + '[list=disc][*]item[/list]', + '[list=disc:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item circle', + '[list=circle][*]item[/list]', + '[list=circle:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple list-item square', + '[list=square][*]item[/list]', + '[list=square:][*:]item[/list:]', + ), + array( + 'Test default bbcodes: simple img', + '[img]https://area51.phpbb.com/images/area51.png[/img]', + '[img:]https://area51.phpbb.com/images/area51.png[/img:]', + ), + array( + 'Test default bbcodes: simple url', + '[url]https://area51.phpbb.com/[/url]', + '[url:]https://area51.phpbb.com/[/url:]', + ), + array( + 'Test default bbcodes: simple url with description', + '[url=https://area51.phpbb.com/]Area51[/url]', + '[url=https://area51.phpbb.com/:]Area51[/url:]', + ), + array( + 'Test default bbcodes: simple email', + '[email]bbcode-test@phpbb.com[/email]', + '[email:]bbcode-test@phpbb.com[/email:]', + ), + array( + 'Test default bbcodes: simple email with description', + '[email=bbcode-test@phpbb.com]Email[/email]', + '[email=bbcode-test@phpbb.com:]Email[/email:]', + ), + ); + } - $result = $parser->first_pass('[i]Italic [u]underlined text[/u][/i]'); - $result = $parser->second_pass($result); - $expected = 'Italic underlined text'; + /** + * @dataProvider string_bbcode_data + */ + public function test_firstpass($description, $message, $expected) + { + $this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.'); - $this->assertEquals($expected, $result, 'Simple nested BBCode first+second pass'); + global $user, $request; + $user = new phpbb_mock_user; + $request = new phpbb_mock_request; + + $bbcode = new bbcode_firstpass(); + $bbcode->message = $message; + $bbcode->bbcode_init(false); + $bbcode->parse_bbcode(); + $this->assertEquals($expected, $bbcode->message); } } From ade9f831aa151de428c4d2b33fce48f9733db336 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 12:58:57 +0100 Subject: [PATCH 02/10] [ticket/11250] Move quote special cases from class to unit tests PHPBB3-11250 --- phpBB/includes/message_parser.php | 11 ----------- tests/bbcode/parser_test.php | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 1cd2a46fa1..44960dd78d 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -702,17 +702,6 @@ class bbcode_firstpass extends bbcode { global $config, $user; - /** - * If you change this code, make sure the cases described within the following reports are still working: - * #3572 - [quote="[test]test"]test [ test[/quote] - (correct: parsed) - * #14667 - [quote]test[/quote] test ] and [ test [quote]test[/quote] (correct: parsed) - * #14770 - [quote="["]test[/quote] (correct: parsed) - * [quote="[i]test[/i]"]test[/quote] (correct: parsed) - * [quote="[quote]test[/quote]"]test[/quote] (correct: parsed - Username displayed as [quote]test[/quote]) - * #20735 - [quote]test[/[/b]quote] test [/quote][/quote] test - (correct: quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted) - * #40565 - [quote="a"]a[/quote][quote="a]a[/quote] (correct: first quote tag parsed, second quote tag unparsed) - */ - $in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in))); if (!$in) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 697bcde610..410eeabe92 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -137,6 +137,32 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[email=bbcode-test@phpbb.com]Email[/email]', '[email=bbcode-test@phpbb.com:]Email[/email:]', ), + + array( + 'PHPBB3-1401 - correct: parsed', + '[quote="[test]test"]test [ test[/quote]', + '[quote="[test]test":]test [ test[/quote:]', + ), + array( + 'PHPBB3-6117 - correct: parsed', + '[quote]test[/quote] test ] and [ test [quote]test[/quote]', + '[quote:]test[/quote:] test ] and [ test [quote:]test[/quote:]', + ), + array( + 'PHPBB3-6200 - correct: parsed', + '[quote="["]test[/quote]', + '[quote="[":]test[/quote:]', + ), + array( + 'PHPBB3-9364 - quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted', + '[quote]test[/[/b]quote] test [/quote][/quote] test', + '[quote:]test[/[/b]quote] test [/quote:][/quote] test', + ), + array( + 'PHPBB3-8096 - first quote tag parsed, second quote tag unparsed', + '[quote="a"]a[/quote][quote="a]a[/quote]', + '[quote="a":]a[/quote:][quote="a]a[/quote]', + ), ); } From deceeb737335b0724c9a15c1f7332ec6deddc3f3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 13:00:14 +0100 Subject: [PATCH 03/10] [ticket/11250] Add some more tests for quotes PHPBB3-11250 --- tests/bbcode/parser_test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 410eeabe92..f700177498 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -163,6 +163,32 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[quote="a"]a[/quote][quote="a]a[/quote]', '[quote="a":]a[/quote:][quote="a]a[/quote]', ), + + array( + 'Allow textual BBcodes in usernames', + '[quote="[i]test[/i]"]test[/quote]', + '[quote="[i:]test[/i:]":]test[/quote:]', + ), + array( + 'Allow links BBcodes in usernames', + '[quote="[url=http://www.phpbb.com/]test[/url]"]test[/quote]', + '[quote="[url=http://www.phpbb.com/:]test[/url:]":]test[/quote:]', + ), + array( + 'Disallow img BBcodes in usernames - Username displayed as [img]http://www.phpbb.com/[/img]', + '[quote="[img]http://www.phpbb.com/[/img]"]test[/quote]', + '[quote="[img]http://www.phpbb.com/[/img]":]test[/quote:]', + ), + array( + 'Disallow flash BBcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]', + '[quote="[flash]http://www.phpbb.com/[/flash]"]test[/quote]', + '[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]', + ), + array( + 'parsed - Username displayed as [quote]test[/quote]', + '[quote="[quote]test[/quote]"]test[/quote]', + '[quote="[quote]test[/quote]":]test[/quote:]', + ), ); } From 90a81a064bd119792a2848c3699d1f1ec0ad1827 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 13:03:10 +0100 Subject: [PATCH 04/10] [ticket/11250] Add some comments and fix a description PHPBB3-11250 --- tests/bbcode/parser_test.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index f700177498..ed55a69640 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -2,15 +2,11 @@ /** * * @package testing -* @version $Id$ -* @copyright (c) 2008 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -// require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode/bbcode_parser_base.php'; -// require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode/bbcode_parser.php'; - class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase { public function string_bbcode_data() @@ -138,6 +134,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[email=bbcode-test@phpbb.com:]Email[/email:]', ), + // Special cases for quote which were reported as bugs before array( 'PHPBB3-1401 - correct: parsed', '[quote="[test]test"]test [ test[/quote]', @@ -164,6 +161,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[quote="a":]a[/quote:][quote="a]a[/quote]', ), + // Nesting bbcodes into quote usernames array( 'Allow textual BBcodes in usernames', '[quote="[i]test[/i]"]test[/quote]', @@ -185,7 +183,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]', ), array( - 'parsed - Username displayed as [quote]test[/quote]', + 'Disallow quote BBcodes in usernames - Username displayed as [quote]test[/quote]', '[quote="[quote]test[/quote]"]test[/quote]', '[quote="[quote]test[/quote]":]test[/quote:]', ), From bf312b529384890e1e45a0b073277156b5ab4c5b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 13:04:44 +0100 Subject: [PATCH 05/10] [ticket/11250] Fix method names PHPBB3-11250 --- tests/bbcode/parser_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index ed55a69640..8f0aeab386 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -9,7 +9,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase { - public function string_bbcode_data() + public function bbcode_firstpass_data() { return array( // Default BBCodes from in their simplest way @@ -192,9 +192,9 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase /** - * @dataProvider string_bbcode_data + * @dataProvider bbcode_firstpass_data */ - public function test_firstpass($description, $message, $expected) + public function test_bbcode_firstpass($description, $message, $expected) { $this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.'); From cce821f99d1ad83b029c31baf84328d257cced23 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 13:09:05 +0100 Subject: [PATCH 06/10] [ticket/11250] Add tests for size and attachment PHPBB3-11250 --- tests/bbcode/parser_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 8f0aeab386..32e23236f6 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -38,6 +38,11 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[color=red]colored[/color]', '[color=red:]colored[/color:]', ), + array( + 'Test default bbcodes: simple size', + '[size=75]smaller[/size]', + '[size=75:]smaller[/size:]', + ), array( 'Test default bbcodes: simple quote', '[quote]quoted[/quote]', @@ -133,6 +138,11 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[email=bbcode-test@phpbb.com]Email[/email]', '[email=bbcode-test@phpbb.com:]Email[/email:]', ), + array( + 'Test default bbcodes: simple attachment', + '[attachment=0]filename[/attachment]', + '[attachment=0:]filename[/attachment:]', + ), // Special cases for quote which were reported as bugs before array( From 1e5da1417ad051a16383c967488d88394b3698ae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 13:58:39 +0100 Subject: [PATCH 07/10] [ticket/11250] Fix parsing result with special chars : . and [ are replaced by their html representation if they are text only PHPBB3-11250 --- tests/bbcode/parser_test.php | 75 +++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 32e23236f6..0e1f405bae 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -7,6 +7,11 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; + class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase { public function bbcode_firstpass_data() @@ -50,8 +55,8 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase ), array( 'Test default bbcodes: simple quote with username', - '[quote="username"]quoted[/quote]', - '[quote="username":]quoted[/quote:]', + '[quote="username"]quoted[/quote]', + '[quote="username":]quoted[/quote:]', ), array( 'Test default bbcodes: simple code', @@ -61,12 +66,12 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase array( 'Test default bbcodes: simple php code', '[code=php]unparsed code[/code]', - '[code=php:]unparsed code[/code:]', + '[code=php:]unparsed code[/code:]', ), array( 'Test default bbcodes: simple list', '[list]no item[/list]', - '[list:]no item[/list:]', + '[list:]no item[/list:u:]', ), array( 'Test default bbcodes: simple list-item only', @@ -76,79 +81,79 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase array( 'Test default bbcodes: simple list-item', '[list][*]item[/list]', - '[list:][*:]item[/list:]', + '[list:][*:]item[/*:m:][/list:u:]', ), array( 'Test default bbcodes: simple list-item closed', '[list][*]item[/*][/list]', - '[list:][*:]item[/*:][/list:]', + '[list:][*:]item[/*:][/list:u:]', ), array( 'Test default bbcodes: simple list-item numbered', '[list=1][*]item[/list]', - '[list=1:][*:]item[/list:]', + '[list=1:][*:]item[/*:m:][/list:o:]', ), array( 'Test default bbcodes: simple list-item alpha', '[list=a][*]item[/list]', - '[list=a:][*:]item[/list:]', + '[list=a:][*:]item[/*:m:][/list:o:]', ), array( 'Test default bbcodes: simple list-item roman', '[list=i][*]item[/list]', - '[list=i:][*:]item[/list:]', + '[list=i:][*:]item[/*:m:][/list:o:]', ), array( 'Test default bbcodes: simple list-item disc', '[list=disc][*]item[/list]', - '[list=disc:][*:]item[/list:]', + '[list=disc:][*:]item[/*:m:][/list:u:]', ), array( 'Test default bbcodes: simple list-item circle', '[list=circle][*]item[/list]', - '[list=circle:][*:]item[/list:]', + '[list=circle:][*:]item[/*:m:][/list:u:]', ), array( 'Test default bbcodes: simple list-item square', '[list=square][*]item[/list]', - '[list=square:][*:]item[/list:]', + '[list=square:][*:]item[/*:m:][/list:u:]', ), array( 'Test default bbcodes: simple img', '[img]https://area51.phpbb.com/images/area51.png[/img]', - '[img:]https://area51.phpbb.com/images/area51.png[/img:]', + '[img:]https://area51.phpbb.com/images/area51.png[/img:]', ), array( 'Test default bbcodes: simple url', '[url]https://area51.phpbb.com/[/url]', - '[url:]https://area51.phpbb.com/[/url:]', + '[url:]https://area51.phpbb.com/[/url:]', ), array( 'Test default bbcodes: simple url with description', '[url=https://area51.phpbb.com/]Area51[/url]', - '[url=https://area51.phpbb.com/:]Area51[/url:]', + '[url=https://area51.phpbb.com/:]Area51[/url:]', ), array( 'Test default bbcodes: simple email', '[email]bbcode-test@phpbb.com[/email]', - '[email:]bbcode-test@phpbb.com[/email:]', + '[email:]bbcode-test@phpbb.com[/email:]', ), array( 'Test default bbcodes: simple email with description', '[email=bbcode-test@phpbb.com]Email[/email]', - '[email=bbcode-test@phpbb.com:]Email[/email:]', + '[email=bbcode-test@phpbb.com:]Email[/email:]', ), array( 'Test default bbcodes: simple attachment', '[attachment=0]filename[/attachment]', - '[attachment=0:]filename[/attachment:]', + '[attachment=0:]filename[/attachment:]', ), // Special cases for quote which were reported as bugs before array( 'PHPBB3-1401 - correct: parsed', - '[quote="[test]test"]test [ test[/quote]', - '[quote="[test]test":]test [ test[/quote:]', + '[quote="[test]test"]test [ test[/quote]', + '[quote="[test]test":]test [ test[/quote:]', ), array( 'PHPBB3-6117 - correct: parsed', @@ -157,8 +162,8 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase ), array( 'PHPBB3-6200 - correct: parsed', - '[quote="["]test[/quote]', - '[quote="[":]test[/quote:]', + '[quote="["]test[/quote]', + '[quote="[":]test[/quote:]', ), array( 'PHPBB3-9364 - quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted', @@ -167,35 +172,35 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase ), array( 'PHPBB3-8096 - first quote tag parsed, second quote tag unparsed', - '[quote="a"]a[/quote][quote="a]a[/quote]', - '[quote="a":]a[/quote:][quote="a]a[/quote]', + '[quote="a"]a[/quote][quote="a]a[/quote]', + '[quote="a":]a[/quote:][quote="a]a[/quote]', ), // Nesting bbcodes into quote usernames array( 'Allow textual BBcodes in usernames', - '[quote="[i]test[/i]"]test[/quote]', - '[quote="[i:]test[/i:]":]test[/quote:]', + '[quote="[i]test[/i]"]test[/quote]', + '[quote="[i:]test[/i:]":]test[/quote:]', ), array( 'Allow links BBcodes in usernames', - '[quote="[url=http://www.phpbb.com/]test[/url]"]test[/quote]', - '[quote="[url=http://www.phpbb.com/:]test[/url:]":]test[/quote:]', + '[quote="[url=https://area51.phpbb.com/]test[/url]"]test[/quote]', + '[quote="[url=https://area51.phpbb.com/:]test[/url:]":]test[/quote:]', ), array( - 'Disallow img BBcodes in usernames - Username displayed as [img]http://www.phpbb.com/[/img]', - '[quote="[img]http://www.phpbb.com/[/img]"]test[/quote]', - '[quote="[img]http://www.phpbb.com/[/img]":]test[/quote:]', + 'Allow img BBcodes in usernames - Username displayed the image', + '[quote="[img]https://area51.phpbb.com/images/area51.png[/img]"]test[/quote]', + '[quote="[img:]https://area51.phpbb.com/images/area51.png[/img:]":]test[/quote:]', ), array( 'Disallow flash BBcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]', - '[quote="[flash]http://www.phpbb.com/[/flash]"]test[/quote]', - '[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]', + '[quote="[flash]http://www.phpbb.com/[/flash]"]test[/quote]', + '[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]', ), array( 'Disallow quote BBcodes in usernames - Username displayed as [quote]test[/quote]', - '[quote="[quote]test[/quote]"]test[/quote]', - '[quote="[quote]test[/quote]":]test[/quote:]', + '[quote="[quote]test[/quote]"]test[/quote]', + '[quote="[quote]test[/quote]":]test[/quote:]', ), ); } From 8bbf3a788fd14a0c9dd67e985d401ce19c1da8a5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 13:59:48 +0100 Subject: [PATCH 08/10] [ticket/11250] Run tests by default and add an option for incomplete ones PHPBB3-11250 --- tests/bbcode/parser_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 0e1f405bae..be5cb8524e 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -211,7 +211,10 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase */ public function test_bbcode_firstpass($description, $message, $expected) { - $this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.'); + if ($incomplete) + { + $this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.'); + } global $user, $request; $user = new phpbb_mock_user; From 4f080ba0d66846ced15295cb0813245d54bd1833 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 14:29:11 +0100 Subject: [PATCH 09/10] [ticket/11250] Add tests for simple nesting and code PHPBB3-11250 --- tests/bbcode/parser_test.php | 51 +++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index be5cb8524e..b87c3668a9 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -17,7 +17,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase public function bbcode_firstpass_data() { return array( - // Default BBCodes from in their simplest way + // Default bbcodes from in their simplest way array( 'Test default bbcodes: simple bold', '[b]bold[/b]', @@ -176,32 +176,69 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase '[quote="a":]a[/quote:][quote="a]a[/quote]', ), + // Simple bbcodes nesting + array( + 'Allow textual bbcodes in textual bbcodes', + '[b]bold [i]bold + italic[/i][/b]', + '[b:]bold [i:]bold + italic[/i:][/b:]', + ), + array( + 'Allow textual bbcodes in url with description', + '[url=https://area51.phpbb.com/]Area51 [i]italic[/i][/url]', + '[url=https://area51.phpbb.com/:]Area51 [i:]italic[/i:][/url:]', + ), + array( + 'Allow url with description in textual bbcodes', + '[i]italic [url=https://area51.phpbb.com/]Area51[/url][/i]', + '[i:]italic [url=https://area51.phpbb.com/:]Area51[/url:][/i:]', + ), + // Nesting bbcodes into quote usernames array( - 'Allow textual BBcodes in usernames', + 'Allow textual bbcodes in usernames', '[quote="[i]test[/i]"]test[/quote]', '[quote="[i:]test[/i:]":]test[/quote:]', ), array( - 'Allow links BBcodes in usernames', + 'Allow links bbcodes in usernames', '[quote="[url=https://area51.phpbb.com/]test[/url]"]test[/quote]', '[quote="[url=https://area51.phpbb.com/:]test[/url:]":]test[/quote:]', ), array( - 'Allow img BBcodes in usernames - Username displayed the image', + 'Allow img bbcodes in usernames - Username displayed the image', '[quote="[img]https://area51.phpbb.com/images/area51.png[/img]"]test[/quote]', '[quote="[img:]https://area51.phpbb.com/images/area51.png[/img:]":]test[/quote:]', ), array( - 'Disallow flash BBcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]', + 'Disallow flash bbcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]', '[quote="[flash]http://www.phpbb.com/[/flash]"]test[/quote]', '[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]', ), array( - 'Disallow quote BBcodes in usernames - Username displayed as [quote]test[/quote]', + 'Disallow quote bbcodes in usernames - Username displayed as [quote]test[/quote]', '[quote="[quote]test[/quote]"]test[/quote]', '[quote="[quote]test[/quote]":]test[/quote:]', ), + + // Do not parse bbcodes in code boxes + array( + 'Do not parse textual bbcodes in code', + '[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]', + '[code:]unparsed code [b]bold [i]bold + italic[/i][/b][/code:]', + ), + array( + 'Do not parse quote bbcodes in code', + '[code]unparsed code [quote="username"]quoted[/quote][/code]', + '[code:]unparsed code [quote="username"]quoted[/quote][/code:]', + ), + + // New user friendly mixed nesting + array( + 'Textual bbcode nesting into textual bbcode', + '[b]bold [i]bold + italic[/b] italic[/i]', + '[b:]bold [i:]bold + italic[/b:] italic[/i:]', + 'Incomplete: secondpass parses as [b:]bold [i:]bold + italic[/i:] italic[/b:]', + ), ); } @@ -209,7 +246,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase /** * @dataProvider bbcode_firstpass_data */ - public function test_bbcode_firstpass($description, $message, $expected) + public function test_bbcode_firstpass($description, $message, $expected, $incomplete = false) { if ($incomplete) { From ebe1f5d8dace9c3899432706f21a8dc8403fc350 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Dec 2012 18:31:12 +0100 Subject: [PATCH 10/10] [ticket/11250] Use user defined message as incomplete message PHPBB3-11250 --- tests/bbcode/parser_test.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index b87c3668a9..d0dcce5bbf 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -237,12 +237,11 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase 'Textual bbcode nesting into textual bbcode', '[b]bold [i]bold + italic[/b] italic[/i]', '[b:]bold [i:]bold + italic[/b:] italic[/i:]', - 'Incomplete: secondpass parses as [b:]bold [i:]bold + italic[/i:] italic[/b:]', + 'Incomplete test case: secondpass parses as [b:]bold [i:]bold + italic[/i:] italic[/b:]', ), ); } - /** * @dataProvider bbcode_firstpass_data */ @@ -250,7 +249,7 @@ class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase { if ($incomplete) { - $this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.'); + $this->markTestIncomplete($incomplete); } global $user, $request;