Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 52 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_get_banned_user_ids_test | |
0.00% |
0 / 51 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| getDataSet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setUp | |
0.00% |
0 / 31 |
|
0.00% |
0 / 1 |
2 | |||
| phpbb_get_banned_user_ids_data | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
2 | |||
| test_phpbb_get_banned_user_ids | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 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__ . '/../../phpBB/includes/functions_user.php'; |
| 15 | |
| 16 | class phpbb_get_banned_user_ids_test extends phpbb_database_test_case |
| 17 | { |
| 18 | public function getDataSet() |
| 19 | { |
| 20 | return $this->createXMLDataSet(__DIR__ . '/fixtures/banned_users.xml'); |
| 21 | } |
| 22 | |
| 23 | protected function setUp(): void |
| 24 | { |
| 25 | global $db, $phpbb_container, $phpbb_root_path, $phpEx; |
| 26 | |
| 27 | $db = $this->new_dbal(); |
| 28 | |
| 29 | parent::setUp(); |
| 30 | |
| 31 | $phpbb_container = new phpbb_mock_container_builder(); |
| 32 | $config = new \phpbb\config\config([]); |
| 33 | $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); |
| 34 | $language = new phpbb\language\language(new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); |
| 35 | $user = new phpbb\user($language, '\phpbb\datetime'); |
| 36 | $user->data['user_email'] = ''; |
| 37 | |
| 38 | $cache = new \phpbb\cache\service( |
| 39 | new \phpbb\cache\driver\dummy(), |
| 40 | $config, |
| 41 | $db, |
| 42 | $phpbb_dispatcher, |
| 43 | $phpbb_root_path, |
| 44 | $phpEx |
| 45 | ); |
| 46 | $cache->get_driver()->purge(); |
| 47 | |
| 48 | $ban_type_email = new \phpbb\ban\type\email($db, 'phpbb_bans', 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); |
| 49 | $ban_type_user = new \phpbb\ban\type\user($db, 'phpbb_bans', 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); |
| 50 | $ban_type_ip = new \phpbb\ban\type\ip($db, 'phpbb_bans', 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); |
| 51 | $phpbb_container->set('ban.type.email', $ban_type_email); |
| 52 | $phpbb_container->set('ban.type.user', $ban_type_user); |
| 53 | $phpbb_container->set('ban.type.ip', $ban_type_ip); |
| 54 | $collection = new \phpbb\di\service_collection($phpbb_container); |
| 55 | $collection->add('ban.type.email'); |
| 56 | $collection->add('ban.type.user'); |
| 57 | $collection->add('ban.type.ip'); |
| 58 | $phpbb_log = new \phpbb\log\dummy(); |
| 59 | |
| 60 | $ban_manager = new \phpbb\ban\manager($collection, $cache->get_driver(), $db, $language, $phpbb_log, $user, 'phpbb_bans', 'phpbb_users'); |
| 61 | $phpbb_container->set('ban.manager', $ban_manager); |
| 62 | } |
| 63 | |
| 64 | public static function phpbb_get_banned_user_ids_data() |
| 65 | { |
| 66 | return array( |
| 67 | // Input to phpbb_get_banned_user_ids (user_id list, ban_end) |
| 68 | // Expected output |
| 69 | array( |
| 70 | // True to get users currently banned |
| 71 | array(array(1, 2, 4, 5, 6), true), |
| 72 | array(2 => 2, 5 => 5), |
| 73 | ), |
| 74 | array( |
| 75 | // False to only get permanently banned users |
| 76 | array(array(1, 2, 4, 5, 6), false), |
| 77 | array(2 => 2), |
| 78 | ), |
| 79 | array( |
| 80 | // True to get users currently banned, but should only return passed user IDs |
| 81 | array(array(5, 6, 7), true), |
| 82 | array(5 => 5), |
| 83 | ), |
| 84 | array( |
| 85 | // Unix timestamp to get users banned until that time |
| 86 | array(array(1, 2, 4, 5, 6), 2), |
| 87 | array(2 => 2, 5 => 5, 6 => 6), |
| 88 | ), |
| 89 | ); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @dataProvider phpbb_get_banned_user_ids_data |
| 94 | */ |
| 95 | public function test_phpbb_get_banned_user_ids($input, $expected) |
| 96 | { |
| 97 | $this->assertEquals($expected, call_user_func_array('phpbb_get_banned_user_ids', $input)); |
| 98 | } |
| 99 | } |