diff options
author | Nils Adermann <naderman@naderman.de> | 2011-06-09 22:39:28 +0200 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2011-06-09 22:39:28 +0200 |
commit | 928ee43881b30d6f15dc1a5b56aeae425ac47b4d (patch) | |
tree | 16d9110d6081ca5617bcdb3d790bb6ca7e027933 /tests | |
parent | d783211f823d3c2d8c05eccb35797fd68fde5e0b (diff) | |
parent | c93164db587391aaff7dd810d07cd0671c8bce3c (diff) | |
download | forums-928ee43881b30d6f15dc1a5b56aeae425ac47b4d.tar forums-928ee43881b30d6f15dc1a5b56aeae425ac47b4d.tar.gz forums-928ee43881b30d6f15dc1a5b56aeae425ac47b4d.tar.bz2 forums-928ee43881b30d6f15dc1a5b56aeae425ac47b4d.tar.xz forums-928ee43881b30d6f15dc1a5b56aeae425ac47b4d.zip |
Merge branch 'ticket/rxu/217' into develop-olympus
* ticket/rxu/217:
[ticket/217] Use positive assertions in tests.
[ticket/217] Silence errors in tests, not code.
[ticket/217] Use positive parameter statement for bbcode_init()
[ticket/217] Adjust patch, add tests
[ticket/217] Multiline [url] not converted
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bbcode/url_bbcode_test.php | 63 | ||||
-rw-r--r-- | tests/mock_user.php | 20 |
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php new file mode 100644 index 0000000000..cd85dbd0d9 --- /dev/null +++ b/tests/bbcode/url_bbcode_test.php @@ -0,0 +1,63 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +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 +{ + public function url_bbcode_test_data() + { + return array( + 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($description, $message, $expected) + { + global $user; + $user = new phpbb_mock_user; + + $bbcode = new bbcode_firstpass(); + $bbcode->message = $message; + $bbcode->bbcode_init(false); + $bbcode->parse_bbcode(); + $this->assertEquals($expected, $bbcode->message); + } +} diff --git a/tests/mock_user.php b/tests/mock_user.php new file mode 100644 index 0000000000..74d31c4c4a --- /dev/null +++ b/tests/mock_user.php @@ -0,0 +1,20 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* Mock user class. +* This class is used when tests invoke phpBB code expecting to have a global +* user object, to avoid instantiating the actual user object. +* It has a minimum amount of functionality, just to make tests work. +*/ +class phpbb_mock_user +{ + public $host = "testhost"; + public $page = array('root_script_path' => '/'); +} |