1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 12:03:21 +01:00
php-phpbb/tests/mock_user.php
Callum Macrae 03da3c7c4c [ticket/10240] Added optionset to mock_user in the tests.
Also made optionset use the value set by optionset. We're not checking
whether the option is set or not, because we would just throw an error
if it wasn't set, and it throws an error anyway.

PHPBB3-10240
2011-08-23 13:28:42 +01:00

37 lines
829 B
PHP

<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* 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' => '/');
private $options = array();
public function optionget($item)
{
if (!isset($this->options[$item]))
{
throw new Exception(sprintf("You didn't set the option '%s' on the mock user using optionset.", $item));
}
return $this->options[$item];
}
public function optionset($item, $value)
{
$this->options[$item] = $value;
}
}