Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
20.00% |
2 / 10 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_mock_user | |
20.00% |
2 / 10 |
|
50.00% |
2 / 4 |
50.47 | |
0.00% |
0 / 1 |
| optionget | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| optionset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| check_ban | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
30 | |||
| lang | |
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 | /** |
| 15 | * Mock user class. |
| 16 | * This class is used when tests invoke phpBB code expecting to have a global |
| 17 | * user object, to avoid instantiating the actual user object. |
| 18 | * It has a minimum amount of functionality, just to make tests work. |
| 19 | */ |
| 20 | class phpbb_mock_user |
| 21 | { |
| 22 | public $host = "testhost"; |
| 23 | public $page = array('root_script_path' => '/'); |
| 24 | public $style = []; |
| 25 | public $data = []; |
| 26 | public $lang = []; |
| 27 | public $ip = ''; |
| 28 | public $module; |
| 29 | public $session_id; |
| 30 | |
| 31 | private $options = array(); |
| 32 | public function optionget($item, $data = false) |
| 33 | { |
| 34 | if (!isset($this->options[$item])) |
| 35 | { |
| 36 | throw new Exception(sprintf("You didn't set the option '%s' on the mock user using optionset.", $item)); |
| 37 | } |
| 38 | |
| 39 | return $this->options[$item]; |
| 40 | } |
| 41 | |
| 42 | public function optionset($item, $value, $data = false) |
| 43 | { |
| 44 | $this->options[$item] = $value; |
| 45 | } |
| 46 | |
| 47 | public function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) |
| 48 | { |
| 49 | $banned_users = $this->optionget('banned_users'); |
| 50 | foreach ($banned_users as $banned) |
| 51 | { |
| 52 | if ($banned == $user_id || $banned == $user_ips || $banned == $user_email) |
| 53 | { |
| 54 | return true; |
| 55 | } |
| 56 | } |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | public function lang() |
| 61 | { |
| 62 | return implode(' ', func_get_args()); |
| 63 | } |
| 64 | } |