diff options
author | Thomas Backlund <tmb@mageia.org> | 2017-05-26 20:02:07 +0300 |
---|---|---|
committer | Thomas Backlund <tmb@mageia.org> | 2017-05-26 20:02:07 +0300 |
commit | 5e6803684739dc0963d784c0cefd86697ad397f3 (patch) | |
tree | 8ab6acff6c8069c5ba3035cba3adec90dba24ba1 /tests/functions_content/get_username_string_test.php | |
parent | 8fc97191a3533a1cce0b051baa55db68d83b5dc4 (diff) | |
parent | 11242dd07d6359a725f22f3674028adfdddb49d6 (diff) | |
download | forums-5e6803684739dc0963d784c0cefd86697ad397f3.tar forums-5e6803684739dc0963d784c0cefd86697ad397f3.tar.gz forums-5e6803684739dc0963d784c0cefd86697ad397f3.tar.bz2 forums-5e6803684739dc0963d784c0cefd86697ad397f3.tar.xz forums-5e6803684739dc0963d784c0cefd86697ad397f3.zip |
Merge tag 'release-3.0.14' of https://github.com/phpbb/phpbb
Merge upstream 3.0.14 release.
Diffstat (limited to 'tests/functions_content/get_username_string_test.php')
-rw-r--r-- | tests/functions_content/get_username_string_test.php | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php new file mode 100644 index 0000000000..48e8936cc1 --- /dev/null +++ b/tests/functions_content/get_username_string_test.php @@ -0,0 +1,125 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2014 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'; + +class phpbb_functions_content_get_username_string_test extends phpbb_test_case +{ + public function setUp() + { + parent::setUp(); + + global $auth, $user; + $auth = $this->getMock('auth'); + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap(array( + array('u_viewprofile', true), + ))); + $user->data['user_id'] = ANONYMOUS; + $user->lang['GUEST'] = 'Guest'; + } + + public function get_username_string_profile_data() + { + global $phpbb_root_path, $phpEx; + + return array( + array(ANONYMOUS, 'Anonymous', '', false, false, ''), + array(2, 'Administrator', 'FF0000', false, false, "{$phpbb_root_path}memberlist.$phpEx?mode=viewprofile&u=2"), + array(42, 'User42', '', false, 'http://www.example.org/user.php?mode=show', 'http://www.example.org/user.php?mode=show&u=42'), + ); + } + + /** + * @dataProvider get_username_string_profile_data + */ + public function test_get_username_string_profile($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected) + { + $this->assertEquals($expected, get_username_string('profile', $user_id, $username, $user_colour, $guest_username, $custom_profile_url)); + } + + public function get_username_string_username_data() + { + return array( + array(ANONYMOUS, '', '', false, false, 'Guest'), + array(ANONYMOUS, '', '', 'CustomName', false, 'CustomName'), + array(2, 'User2', '', false, false, 'User2'), + array(5, 'User5', '', 'Anonymous', false, 'User5'), + array(128, 'User128', '', false, false, 'User128'), + ); + } + + /** + * @dataProvider get_username_string_username_data + */ + public function test_get_username_string_username($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected) + { + $this->assertEquals($expected, get_username_string('username', $user_id, $username, $user_colour, $guest_username, $custom_profile_url)); + } + + public function get_username_string_colour_data() + { + return array( + array(0, '', '', false, false, ''), + array(0, '', 'F0F0F0', false, false, '#F0F0F0'), + array(ANONYMOUS, 'Anonymous', '000000', false, false, '#000000'), + array(2, 'Administrator', '', false, false, ''), + ); + } + + /** + * @dataProvider get_username_string_colour_data + */ + public function test_get_username_string_colour($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected) + { + $this->assertEquals($expected, get_username_string('colour', $user_id, $username, $user_colour, $guest_username, $custom_profile_url)); + } + + public function get_username_string_full_data() + { + global $phpbb_root_path, $phpEx; + + return array( + array(0, '', '', false, false, 'Guest'), + array(ANONYMOUS, 'Anonymous', '', false, false, 'Anonymous'), + array(2, 'Administrator', 'FF0000', false, false, '<a href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=viewprofile&u=2" style="color: #FF0000;" class="username-coloured">Administrator</a>'), + array(5, 'User5', '', false, 'http://www.example.org/user.php?mode=show', '<a href="http://www.example.org/user.php?mode=show&u=5">User5</a>'), + array(8, 'Eight', '', false, false, '<a href="' . $phpbb_root_path . 'memberlist.php?mode=viewprofile&u=8">Eight</a>'), + ); + } + + /** + * @dataProvider get_username_string_full_data + */ + public function test_get_username_string_full($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected) + { + $this->assertEquals($expected, get_username_string('full', $user_id, $username, $user_colour, $guest_username, $custom_profile_url)); + } + + public function get_username_string_no_profile_data() + { + return array( + array(ANONYMOUS, 'Anonymous', '', false, false, 'Anonymous'), + array(ANONYMOUS, 'Anonymous', '', '', false, 'Guest'), + array(2, 'Administrator', 'FF0000', false, false, '<span style="color: #FF0000;" class="username-coloured">Administrator</span>'), + array(8, 'Eight', '', false, false, 'Eight'), + ); + } + + /** + * @dataProvider get_username_string_no_profile_data + */ + public function test_get_username_string_no_profile($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected) + { + $this->assertEquals($expected, get_username_string('no_profile', $user_id, $username, $user_colour, $guest_username, $custom_profile_url)); + } +} |