aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mock
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-02-24 00:06:05 +0100
committerNils Adermann <naderman@naderman.de>2011-02-24 01:12:53 +0100
commitaae3bd0c72835939acb1bf88d3d63883ad66c2f4 (patch)
treee98b8f1f7186bc1d03dc82fe92ece9e926a7f39c /tests/mock
parente3c854288c6ef75b9fd92b97f9a90b71f3164724 (diff)
parent510248da2844df22af1cd807e13b46c0c8b68290 (diff)
downloadforums-aae3bd0c72835939acb1bf88d3d63883ad66c2f4.tar
forums-aae3bd0c72835939acb1bf88d3d63883ad66c2f4.tar.gz
forums-aae3bd0c72835939acb1bf88d3d63883ad66c2f4.tar.bz2
forums-aae3bd0c72835939acb1bf88d3d63883ad66c2f4.tar.xz
forums-aae3bd0c72835939acb1bf88d3d63883ad66c2f4.zip
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
Diffstat (limited to 'tests/mock')
-rw-r--r--tests/mock/request.php46
-rw-r--r--tests/mock/session_testable.php7
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/mock/request.php b/tests/mock/request.php
new file mode 100644
index 0000000000..da4015e78b
--- /dev/null
+++ b/tests/mock/request.php
@@ -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]);
+ }
+}
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index 0d4642d372..47089cb94b 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -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();