Created
December 14, 2012 11:22
-
-
Save nickvergessen/4284736 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @package testing | |
* @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/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_bbcode_test extends phpbb_test_case | |
{ | |
public function string_bbcode_data() | |
{ | |
return array( | |
array( | |
'bold', | |
'[b]bold[/b]', | |
'[b:]bold[/b:]' | |
), | |
array( | |
'bold only', | |
'[b][i]bold[/b]', | |
'[b:][i]bold[/b:]' | |
), | |
array( | |
'italic', | |
'[i]italic[/i]', | |
'[i:]italic[/i:]' | |
), | |
array( | |
'mixed', | |
'[b]bold [i]bold and italic[/b] italic[/i]', | |
'[b:]bold [i:]bold and italic[/b:] italic[/i:]' | |
), | |
array( | |
'url only', | |
'[url=http://www.phpbb.com/community/][quote]bold[/url][/quote]', | |
'[url=http://www.phpbb.com/community/:][quote]bold[/url:][/quote]', | |
), | |
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( | |
'Allow some 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', | |
'[quote="[img]http://www.phpbb.com/[/img]"]test[/quote]', | |
'[quote="[img]http://www.phpbb.com/[/img]":]test[/quote:]', | |
), | |
array( | |
'Disallow flash BBcodes in usernames', | |
'[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:]', | |
), | |
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]', | |
), | |
); | |
} | |
/** | |
* @dataProvider string_bbcode_data | |
*/ | |
public function test_string_bbcode($description, $message, $expected) | |
{ | |
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment