ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
29 {
30  protected $backupGlobals = FALSE;
31 
32  protected function setUp()
33  {
34  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
35  ilUnitUtil::performInitialisation();
36  }
37 
41  public function testBasicSessionBehaviour()
42  {
43  global $ilUser;
44 
45  include_once("./Services/Authentication/classes/class.ilSession.php");
46  $result = "";
47  ilSession::_writeData("123456", "Testdata");
48  if (ilSession::_exists("123456"))
49  {
50  $result.= "exists-";
51  }
52  if (ilSession::_getData("123456") == "Testdata")
53  {
54  $result.= "write-get-";
55  }
56  $duplicate = ilSession::_duplicate("123456");
57  if (ilSession::_getData($duplicate) == "Testdata")
58  {
59  $result.= "duplicate-";
60  }
61  ilSession::_destroy("123456");
62  if (!ilSession::_exists("123456"))
63  {
64  $result.= "destroy-";
65  }
67  if (ilSession::_exists($duplicate))
68  {
69  $result.= "destroyExp-";
70  }
71 
72  ilSession::_destroyByUserId($ilUser->getId());
73  if (!ilSession::_exists($duplicate))
74  {
75  $result.= "destroyByUser-";
76  }
77  $this->assertEquals("exists-write-get-duplicate-destroy-destroyExp-destroyByUser-", $result);
78  }
79 
84  {
85  global $ilUser;
86 
87  include_once("./include/inc.pwassist_session_handler.php");
88 
89  $result = "";
90 
91  // write session
92  db_pwassist_session_write("12345", 60, $ilUser->getId());
93 
94  // find
95  $res = db_pwassist_session_find($ilUser->getId());
96  if ($res["pwassist_id"] == "12345")
97  {
98  $result.= "find-";
99  }
100 
101  // read
102  $res = db_pwassist_session_read("12345");
103  if ($res["user_id"] == $ilUser->getId())
104  {
105  $result.= "read-";
106  }
107 
108  // destroy
110  $res = db_pwassist_session_read("12345");
111  if (!$res)
112  {
113  $result.= "destroy-";
114  }
115 
117 
118  $this->assertEquals("find-read-destroy-", $result);
119  }
120 }
121 ?>
static _destroy($a_session_id, $a_closing_context=null, $a_expired_at=null)
Destroy session.
db_pwassist_session_destroy($pwassist_id)
destroy session
$result
db_pwassist_session_read($pwassist_id)
testBasicSessionBehaviour()
IL_Init
static _destroyExpiredSessions()
Destroy expired sessions.
db_pwassist_session_find($user_id)
static _exists($a_session_id)
Check whether session exists.
Class ilSessionTest needsInstalledILIAS.
$ilUser
Definition: imgupload.php:18
static _getData($a_session_id)
Get session data from table.
static _destroyByUserId($a_user_id)
Destroy session.
static _writeData($a_session_id, $a_data)
Write session data.
static _duplicate($a_session_id)
Duplicate session.
db_pwassist_session_gc()
removes all expired sessions
testPasswordAssisstanceSession()
IL_Init
db_pwassist_session_write($pwassist_id, $maxlifetime, $user_id)
Writes serialized session data to the database.