ILIAS  Release_4_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");
32  }
33 
34  public function testBasicSessionBehaviour()
35  {
36  global $ilUser;
37 
38  include_once("./Services/Authentication/classes/class.ilSession.php");
39  $result = "";
40  ilSession::_writeData("123456", "Testdata");
41  if (ilSession::_exists("123456"))
42  {
43  $result.= "exists-";
44  }
45  if (ilSession::_getData("123456") == "Testdata")
46  {
47  $result.= "write-get-";
48  }
49  $duplicate = ilSession::_duplicate("123456");
50  if (ilSession::_getData($duplicate) == "Testdata")
51  {
52  $result.= "duplicate-";
53  }
54  ilSession::_destroy("123456");
55  if (!ilSession::_exists("123456"))
56  {
57  $result.= "destroy-";
58  }
60  if (ilSession::_exists($duplicate))
61  {
62  $result.= "destroyExp-";
63  }
64 
65  ilSession::_destroyByUserId($ilUser->getId());
66  if (!ilSession::_exists($duplicate))
67  {
68  $result.= "destroyByUser-";
69  }
70  $this->assertEquals("exists-write-get-duplicate-destroy-destroyExp-destroyByUser-", $result);
71  }
72 
74  {
75  global $ilUser;
76 
77  include_once("./include/inc.pwassist_session_handler.php");
78 
79  $result = "";
80 
81  // write session
82  db_pwassist_session_write("12345", 60, $ilUser->getId());
83 
84  // find
85  $res = db_pwassist_session_find($ilUser->getId());
86  if ($res["pwassist_id"] == "12345")
87  {
88  $result.= "find-";
89  }
90 
91  // read
92  $res = db_pwassist_session_read("12345");
93  if ($res["user_id"] == $ilUser->getId())
94  {
95  $result.= "read-";
96  }
97 
98  // destroy
100  $res = db_pwassist_session_read("12345");
101  if (!$res)
102  {
103  $result.= "destroy-";
104  }
105 
107 
108  $this->assertEquals("find-read-destroy-", $result);
109  }
110 }
111 ?>