ILIAS
Release_5_0_x_branch Revision 61816
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
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
24
class
ilSessionTest
extends
PHPUnit_Framework_TestCase
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
}
62
ilSession::_destroyExpiredSessions
();
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
79
public
function
testPasswordAssisstanceSession
()
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
105
db_pwassist_session_destroy
(
"12345"
);
106
$res =
db_pwassist_session_read
(
"12345"
);
107
if
(!$res)
108
{
109
$result
.=
"destroy-"
;
110
}
111
112
db_pwassist_session_gc
();
113
114
$this->assertEquals(
"find-read-destroy-"
,
$result
);
115
}
116
}
117
?>
Services
Authentication
test
ilSessionTest.php
Generated on Wed Apr 27 2016 21:01:29 for ILIAS by
1.8.1.2 (using
Doxyfile
)