aboutsummaryrefslogtreecommitdiffstats
path: root/tests/session/testable_facade.php
blob: f85332c94a2c353cfe58e41f7b4aaa69d69208a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
 *
 * @package testing
 * @copyright (c) 2013 phpBB Group
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
 *
 */

require_once dirname(__FILE__) . '/testable_factory.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';

/**
 * This class exists to expose session.php's functions in a more testable way.
 *
 * Since many functions in session.php have global variables inside the function,
 * this exposes those functions through a testable facade that uses testable_factory's
 * mock global variables to modify global variables used in the functions.
 *
 * This is using the facade pattern to provide a testable "front" to the functions in sessions.php.
 *
 */
class phpbb_session_testable_facade
{
	public static function extract_current_page($db, $session_factory, $root_path, $php_self, $query_string, $request_uri) {
		$session_factory->get_session($db);
		global $request;
		$request->overwrite('PHP_SELF', $php_self, phpbb_request_interface::SERVER);
		$request->overwrite('QUERY_STRING', $query_string, phpbb_request_interface::SERVER);
		$request->overwrite('REQUEST_URI', $request_uri, phpbb_request_interface::SERVER);
		return phpbb_session::extract_current_page($root_path);
	}

	// [To be completed]
	// public static function extract_current_hostname() {}
	// public static function session_begin($update_session_page = true) {}
	// public static function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) {}
	// public static function session_kill($new_session = true) {}
	// public static function session_gc() {}
	// public static function set_cookie($name, $cookiedata, $cookietime) {}
	// public static function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) {}
	// public static function check_dnsbl($mode, $ip = false) {}
	// public static function set_login_key($user_id = false, $key = false, $user_ip = false) {}
	// public static function reset_login_keys($user_id = false) {}
	// public static function validate_referer($check_script_path = false) {}
	// public static function update_session($session_data, $session_id = null) {}
	// public static function unset_admin() {}
}