ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSessionTest.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
25{
26 protected $backupGlobals = FALSE;
27
28 protected function setUp()
29 {
30 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
31 ilUnitUtil::performInitialisation();
32 }
33
37 public function testBasicSessionBehaviour()
38 {
39 global $ilUser;
40
41 include_once("./Services/Authentication/classes/class.ilSession.php");
42 $result = "";
43 ilSession::_writeData("123456", "Testdata");
44 if (ilSession::_exists("123456"))
45 {
46 $result.= "exists-";
47 }
48 if (ilSession::_getData("123456") == "Testdata")
49 {
50 $result.= "write-get-";
51 }
52 $duplicate = ilSession::_duplicate("123456");
53 if (ilSession::_getData($duplicate) == "Testdata")
54 {
55 $result.= "duplicate-";
56 }
57 ilSession::_destroy("123456");
58 if (!ilSession::_exists("123456"))
59 {
60 $result.= "destroy-";
61 }
63 if (ilSession::_exists($duplicate))
64 {
65 $result.= "destroyExp-";
66 }
67
69 if (!ilSession::_exists($duplicate))
70 {
71 $result.= "destroyByUser-";
72 }
73 $this->assertEquals("exists-write-get-duplicate-destroy-destroyExp-destroyByUser-", $result);
74 }
75
80 {
81 global $ilUser;
82
83 include_once("./include/inc.pwassist_session_handler.php");
84
85 $result = "";
86
87 // write session
88 db_pwassist_session_write("12345", 60, $ilUser->getId());
89
90 // find
92 if ($res["pwassist_id"] == "12345")
93 {
94 $result.= "find-";
95 }
96
97 // read
99 if ($res["user_id"] == $ilUser->getId())
100 {
101 $result.= "read-";
102 }
103
104 // destroy
107 if (!$res)
108 {
109 $result.= "destroy-";
110 }
111
113
114 $this->assertEquals("find-read-destroy-", $result);
115 }
116}
117?>
$result
testPasswordAssisstanceSession()
@group IL_Init
testBasicSessionBehaviour()
@group IL_Init
static _exists($a_session_id)
Check whether session exists.
static _writeData($a_session_id, $a_data)
Write session data.
static _destroyExpiredSessions()
Destroy expired sessions.
static _destroy($a_session_id, $a_closing_context=null, $a_expired_at=null)
Destroy session.
static _destroyByUserId($a_user_id)
Destroy session.
static _getData($a_session_id)
Get session data from table.
static _duplicate($a_session_id)
Duplicate session.
db_pwassist_session_destroy($pwassist_id)
destroy session
db_pwassist_session_find($user_id)
db_pwassist_session_write($pwassist_id, $maxlifetime, $user_id)
Writes serialized session data to the database.
db_pwassist_session_read($pwassist_id)
db_pwassist_session_gc()
removes all expired sessions
global $ilUser
Definition: imgupload.php:15