mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-20 07:21:30 +02:00
Merge branch 'develop-olympus' into develop
* develop-olympus: [ticket/10052] Add comments to the session testable factory. [ticket/10052] Correct session tests, and separate session factory from tests
This commit is contained in:
46
tests/mock/request.php
Normal file
46
tests/mock/request.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_mock_request implements phpbb_request_interface
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($get = array(), $post = array(), $cookie = array(), $request = false)
|
||||
{
|
||||
$this->data[phpbb_request_interface::GET] = $get;
|
||||
$this->data[phpbb_request_interface::POST] = $post;
|
||||
$this->data[phpbb_request_interface::COOKIE] = $cookie;
|
||||
$this->data[phpbb_request_interface::REQUEST] = ($request === false) ? $post + $get : $request;
|
||||
}
|
||||
|
||||
public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST)
|
||||
{
|
||||
$this->data[$super_global][$var_name] = $value;
|
||||
}
|
||||
|
||||
public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST)
|
||||
{
|
||||
return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default;
|
||||
}
|
||||
|
||||
public function is_set_post($name)
|
||||
{
|
||||
return $this->is_set($name, phpbb_request_interface::POST);
|
||||
}
|
||||
|
||||
public function is_set($var, $super_global = phpbb_request_interface::REQUEST)
|
||||
{
|
||||
return isset($this->data[$super_global][$var]);
|
||||
}
|
||||
|
||||
public function variable_names($super_global = phpbb_request_interface::REQUEST)
|
||||
{
|
||||
return array_keys($this->data[$super_global]);
|
||||
}
|
||||
}
|
@@ -10,6 +10,13 @@
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
|
||||
|
||||
/**
|
||||
* Extends the session class to overwrite the setting of cookies.
|
||||
*
|
||||
* The session class directly writes cookie headers making it impossible to
|
||||
* test it without warnings about sent headers. This class only stores cookie
|
||||
* data for later verification.
|
||||
*/
|
||||
class phpbb_mock_session_testable extends session
|
||||
{
|
||||
private $_cookies = array();
|
||||
|
Reference in New Issue
Block a user