From 6585d938d2c441900d8af6d25da2433d3beec856 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 5 Jun 2011 21:55:28 +0800 Subject: [ticket/217] Adjust patch, add tests PHPBB3-217 --- tests/bbcode/url_bbcode_test.php | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/bbcode/url_bbcode_test.php (limited to 'tests/bbcode') diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php new file mode 100644 index 0000000000..6d9e51664d --- /dev/null +++ b/tests/bbcode/url_bbcode_test.php @@ -0,0 +1,41 @@ +message = $message; + $bbcode->bbcode_init(true); + $bbcode->parse_bbcode(); + $this->assertNotEquals($bbcode->message, '[url][/url]'); + $this->assertNotEquals($bbcode->message, $message); + $this->assertNotEquals($bbcode->message, NULL); + } +} -- cgit v1.2.1 From d44b6ba5caeafe220b4959a6de99d035fe10b4f1 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 6 Jun 2011 00:50:53 +0800 Subject: [ticket/217] Use positive parameter statement for bbcode_init() PHPBB3-217 --- tests/bbcode/url_bbcode_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/bbcode') diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php index 6d9e51664d..597933c6f8 100644 --- a/tests/bbcode/url_bbcode_test.php +++ b/tests/bbcode/url_bbcode_test.php @@ -32,7 +32,7 @@ class phpbb_url_bbcode_test extends phpbb_test_case { $bbcode = new bbcode_firstpass(); $bbcode->message = $message; - $bbcode->bbcode_init(true); + $bbcode->bbcode_init(false); $bbcode->parse_bbcode(); $this->assertNotEquals($bbcode->message, '[url][/url]'); $this->assertNotEquals($bbcode->message, $message); -- cgit v1.2.1 From 2d1e426ba745fa5b0b7666e5fe4a5fee97caccd7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 5 Jun 2011 13:23:55 -0400 Subject: [ticket/217] Silence errors in tests, not code. Use a mock user object for testing bbcode. PHPBB3-217 --- tests/bbcode/url_bbcode_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/bbcode') diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php index 597933c6f8..7bbf731c74 100644 --- a/tests/bbcode/url_bbcode_test.php +++ b/tests/bbcode/url_bbcode_test.php @@ -11,6 +11,7 @@ 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'; +require_once dirname(__FILE__) . '/../mock_user.php'; class phpbb_url_bbcode_test extends phpbb_test_case { @@ -30,6 +31,9 @@ class phpbb_url_bbcode_test extends phpbb_test_case */ public function test_url($message) { + global $user; + $user = new phpbb_mock_user; + $bbcode = new bbcode_firstpass(); $bbcode->message = $message; $bbcode->bbcode_init(false); -- cgit v1.2.1 From c93164db587391aaff7dd810d07cd0671c8bce3c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 5 Jun 2011 13:48:37 -0400 Subject: [ticket/217] Use positive assertions in tests. PHPBB3-217 --- tests/bbcode/url_bbcode_test.php | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'tests/bbcode') diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php index 7bbf731c74..cd85dbd0d9 100644 --- a/tests/bbcode/url_bbcode_test.php +++ b/tests/bbcode/url_bbcode_test.php @@ -18,18 +18,38 @@ class phpbb_url_bbcode_test extends phpbb_test_case public function url_bbcode_test_data() { return array( - array('[url]http://www.phpbb.com/community/[/url]'), - array('[url=http://www.phpbb.com/community/]One line URL text[/url]'), - array("[url=http://www.phpbb.com/community/]Multiline\x0AURL\x0Atext[/url]"), - array("test [url] test \x0A test [url=http://www.phpbb.com/]test[/url] test"), - array("test [url=http://www.phpbb.com/]test \x0A [url]http://phpbb.com[/url] test"), + array( + 'url only', + '[url]http://www.phpbb.com/community/[/url]', + '[url:]http://www.phpbb.com/community/[/url:]' + ), + array( + 'url with title', + '[url=http://www.phpbb.com/community/]One line URL text[/url]', + '[url=http://www.phpbb.com/community/:]One line URL text[/url:]' + ), + array( + 'url with multiline title', + "[url=http://www.phpbb.com/community/]Multiline\x0AURL\x0Atext[/url]", + "[url=http://www.phpbb.com/community/:]Multiline\x0AURL\x0Atext[/url:]" + ), + array( + 'unclosed url with multiline', + "test [url] test \x0A test [url=http://www.phpbb.com/]test[/url] test", + "test [url] test \x0A test [url=http://www.phpbb.com/:]test[/url:] test" + ), + array( + 'unclosed url with multiline and title', + "test [url=http://www.phpbb.com/]test \x0A [url]http://phpbb.com[/url] test", + "test [url=http://www.phpbb.com/:]test \x0A [url]http://phpbb.com[/url:] test" + ), ); } /** * @dataProvider url_bbcode_test_data */ - public function test_url($message) + public function test_url($description, $message, $expected) { global $user; $user = new phpbb_mock_user; @@ -38,8 +58,6 @@ class phpbb_url_bbcode_test extends phpbb_test_case $bbcode->message = $message; $bbcode->bbcode_init(false); $bbcode->parse_bbcode(); - $this->assertNotEquals($bbcode->message, '[url][/url]'); - $this->assertNotEquals($bbcode->message, $message); - $this->assertNotEquals($bbcode->message, NULL); + $this->assertEquals($expected, $bbcode->message); } } -- cgit v1.2.1