Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
13.51% |
5 / 37 |
|
50.00% |
5 / 10 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_group_helper_get_name_string_test | |
13.51% |
5 / 37 |
|
50.00% |
5 / 10 |
74.69 | |
0.00% |
0 / 1 |
| get_name_string_profile_data | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_name_string_profile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_name_string_group_name_data | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_name_string_group_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_name_string_colour_data | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_name_string_colour | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_name_string_full_data | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_name_string_full | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_name_string_no_profile_data | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_name_string_no_profile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/helper_test_case.php'; |
| 15 | |
| 16 | class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_case |
| 17 | { |
| 18 | |
| 19 | public static function get_name_string_profile_data() |
| 20 | { |
| 21 | global $phpbb_root_path, $phpEx; |
| 22 | |
| 23 | return array( |
| 24 | array(0, 'Non existing group', '', false, ''), |
| 25 | array(2, 'Administrators', 'AA0000', false, "{$phpbb_root_path}memberlist.$phpEx?mode=group&g=2"), |
| 26 | array(42, 'Example Group', '', 'http://www.example.org/group.php?mode=show', 'http://www.example.org/group.php?mode=show&g=42'), |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @dataProvider get_name_string_profile_data |
| 32 | */ |
| 33 | public function test_get_name_string_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected) |
| 34 | { |
| 35 | $this->assertEquals($expected, $this->group_helper->get_name_string('profile', $group_id, $group_name, $group_colour, $custom_profile_url)); |
| 36 | } |
| 37 | |
| 38 | public static function get_name_string_group_name_data() |
| 39 | { |
| 40 | return array( |
| 41 | // Should be fine |
| 42 | array(0, 'BOTS', 'AA0000', false, 'Bots'), |
| 43 | array(1, 'new_group', '', false, 'Some new group'), |
| 44 | array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'), |
| 45 | |
| 46 | // Should fail and thus return the same |
| 47 | array(3, 'not_uppercase', 'FFFFFF', false, 'not_uppercase'), |
| 48 | array(4, 'Awesome group', '', false, 'Awesome group'), |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @dataProvider get_name_string_group_name_data |
| 54 | */ |
| 55 | public function test_get_name_string_group_name($group_id, $group_name, $group_colour, $custom_profile_url, $expected) |
| 56 | { |
| 57 | $this->assertEquals($expected, $this->group_helper->get_name_string('group_name', $group_id, $group_name, $group_colour, $custom_profile_url)); |
| 58 | } |
| 59 | |
| 60 | public static function get_name_string_colour_data() |
| 61 | { |
| 62 | return array( |
| 63 | array(0, '', '', false, ''), |
| 64 | array(0, '', 'F0F0F0', false, '#F0F0F0'), |
| 65 | array(1, 'Guests', '000000', false, '#000000'), |
| 66 | array(2, 'Administrators', '', false, ''), |
| 67 | ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @dataProvider get_name_string_colour_data |
| 72 | */ |
| 73 | public function test_get_name_string_colour($group_id, $group_name, $group_colour, $custom_profile_url, $expected) |
| 74 | { |
| 75 | $this->assertEquals($expected, $this->group_helper->get_name_string('colour', $group_id, $group_name, $group_colour, $custom_profile_url)); |
| 76 | } |
| 77 | |
| 78 | public static function get_name_string_full_data() |
| 79 | { |
| 80 | global $phpbb_root_path, $phpEx; |
| 81 | |
| 82 | return array( |
| 83 | array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'), |
| 84 | array(1, 'BOTS', '111111', false, '<span class="username-coloured" style="color: #111111;">Bots</span>'), |
| 85 | array(7, 'new_group', 'FFA500', false, '<a class="username-coloured" href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=group&g=7" style="color: #FFA500;">Some new group</a>'), |
| 86 | array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<a class="username" href="http://www.example.org/group.php?mode=show&g=14">Awesome group</a>'), |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @dataProvider get_name_string_full_data |
| 92 | */ |
| 93 | public function test_get_name_string_full($group_id, $group_name, $group_colour, $custom_profile_url, $expected) |
| 94 | { |
| 95 | $this->assertEquals($expected, $this->group_helper->get_name_string('full', $group_id, $group_name, $group_colour, $custom_profile_url)); |
| 96 | } |
| 97 | |
| 98 | public static function get_name_string_no_profile_data() |
| 99 | { |
| 100 | return array( |
| 101 | array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'), |
| 102 | array(1, 'new_group', '', false, '<span class="username">Some new group</span>'), |
| 103 | array(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'), |
| 104 | array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<span class="username">Awesome group</span>'), |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @dataProvider get_name_string_no_profile_data |
| 110 | */ |
| 111 | public function test_get_name_string_no_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected) |
| 112 | { |
| 113 | $this->assertEquals($expected, $this->group_helper->get_name_string('no_profile', $group_id, $group_name, $group_colour, $custom_profile_url)); |
| 114 | } |
| 115 | } |