ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
68  ilSession::_destroyByUserId($ilUser->getId());
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
91  $res = db_pwassist_session_find($ilUser->getId());
92  if ($res["pwassist_id"] == "12345")
93  {
94  $result.= "find-";
95  }
96 
97  // read
98  $res = db_pwassist_session_read("12345");
99  if ($res["user_id"] == $ilUser->getId())
100  {
101  $result.= "read-";
102  }
103 
104  // destroy
106  $res = db_pwassist_session_read("12345");
107  if (!$res)
108  {
109  $result.= "destroy-";
110  }
111 
113 
114  $this->assertEquals("find-read-destroy-", $result);
115  }
116 }
117 ?>