aboutsummaryrefslogtreecommitdiffstats
path: root/tests/session/init_test.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-02-20 18:32:33 +0100
committerAndreas Fischer <bantu@phpbb.com>2011-02-20 18:32:33 +0100
commit69449417bac4244c7fc35b7bf6bb5bd056ca2a20 (patch)
treec78de71030aae4b809d831d9e2d1703232101ff0 /tests/session/init_test.php
parent53a6cd607e36ccd099f3d83431bf8bfee48dc7b3 (diff)
parent6902ecf6a97df44b6874c0bf4c9fa28275b7c9f7 (diff)
downloadforums-69449417bac4244c7fc35b7bf6bb5bd056ca2a20.tar
forums-69449417bac4244c7fc35b7bf6bb5bd056ca2a20.tar.gz
forums-69449417bac4244c7fc35b7bf6bb5bd056ca2a20.tar.bz2
forums-69449417bac4244c7fc35b7bf6bb5bd056ca2a20.tar.xz
forums-69449417bac4244c7fc35b7bf6bb5bd056ca2a20.zip
Merge branch 'ticket/p/10049' into develop-olympus
* ticket/p/10049: [ticket/10049] Mark session init test incomplete for now. [ticket/10049] Mark session continue test incomplete for now. [ticket/10049] Globalize $_SID. [ticket/10049] Chase assertResultEquals rename. [ticket/10049] Fixed requires in session tests and mock. [ticket/10049] Renamed session test files to proper file names.
Diffstat (limited to 'tests/session/init_test.php')
-rw-r--r--tests/session/init_test.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/session/init_test.php b/tests/session/init_test.php
new file mode 100644
index 0000000000..ccb0554409
--- /dev/null
+++ b/tests/session/init_test.php
@@ -0,0 +1,77 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/../mock/session_testable.php';
+
+class phpbb_session_init_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
+ }
+
+ // also see security/extract_current_page.php
+
+ public function test_login_session_create()
+ {
+ $this->markTestIncomplete('Test fails when run as part of the test suite');
+
+ $session = new phpbb_mock_session_testable;
+ $session->page = array('page' => 'page', 'forum' => 0);
+
+ // set up all the global variables used in session_create
+ global $SID, $_SID, $db, $config, $cache;
+
+ $config = $this->get_config();
+ $db = $this->new_dbal();
+ $cache_data = array(
+ '_bots' => array(),
+ );
+ $cache = new phpbb_mock_cache;
+ $SID = $_SID = null;
+
+ $session->session_create(3);
+
+ $sql = 'SELECT session_user_id
+ FROM phpbb_sessions';
+
+ $this->assertSqlResultEquals(
+ array(array('session_user_id' => 3)),
+ $sql,
+ 'Check if exacly one session for user id 3 was created'
+ );
+
+ $cookie_expire = $session->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000);
+
+ $session->check_cookies($this, array(
+ 'u' => array(null, $cookie_expire),
+ 'k' => array(null, $cookie_expire),
+ 'sid' => array($_SID, $cookie_expire),
+ ));
+
+ $cache->check($this, $cache_data);
+ }
+
+ static public function get_config()
+ {
+ return array(
+ 'allow_autologin' => false,
+ 'auth_method' => 'db',
+ 'forwarded_for_check' => true,
+ 'active_sessions' => 0, // disable
+ 'rand_seed' => 'foo',
+ 'rand_seed_last_update' => 0,
+ 'max_autologin_time' => 0,
+ 'session_length' => 100,
+ 'form_token_lifetime' => 100,
+ );
+ }
+}
+