2011-06-05 13:23:55 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package testing
|
|
|
|
* @copyright (c) 2011 phpBB Group
|
2011-12-31 16:05:02 +00:00
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
2011-06-05 13:23:55 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mock user class.
|
|
|
|
* This class is used when tests invoke phpBB code expecting to have a global
|
|
|
|
* user object, to avoid instantiating the actual user object.
|
|
|
|
* It has a minimum amount of functionality, just to make tests work.
|
|
|
|
*/
|
|
|
|
class phpbb_mock_user
|
|
|
|
{
|
|
|
|
public $host = "testhost";
|
|
|
|
public $page = array('root_script_path' => '/');
|
2011-08-22 15:35:47 +01:00
|
|
|
|
2011-08-23 12:21:20 +01:00
|
|
|
private $options = array();
|
2011-08-22 15:35:47 +01:00
|
|
|
public function optionget($item)
|
|
|
|
{
|
2011-08-23 12:21:20 +01:00
|
|
|
if (!isset($this->options[$item]))
|
2011-08-22 15:35:47 +01:00
|
|
|
{
|
2011-08-23 12:21:20 +01:00
|
|
|
throw new Exception(sprintf("You didn't set the option '%s' on the mock user using optionset.", $item));
|
2011-08-22 15:35:47 +01:00
|
|
|
}
|
2011-08-23 12:21:20 +01:00
|
|
|
|
|
|
|
return $this->options[$item];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function optionset($item, $value)
|
|
|
|
{
|
|
|
|
$this->options[$item] = $value;
|
2011-08-22 15:35:47 +01:00
|
|
|
}
|
2013-05-30 16:05:19 +02:00
|
|
|
|
|
|
|
public function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
|
|
|
|
{
|
|
|
|
$banned_users = $this->optionget('banned_users');
|
|
|
|
foreach ($banned_users as $banned)
|
|
|
|
{
|
|
|
|
if ($banned == $user_id || $banned == $user_ips || $banned == $user_email)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-06-05 13:23:55 -04:00
|
|
|
}
|