groupManTesting.php
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<html>
<body>
<?php
require ("./config/dmsDefaults.php");
//require ("$default->fileSystemRoot/lib/db.inc");
require ("$default->fileSystemRoot/lib/dms.inc");
require ("$default->fileSystemRoot/lib/administration/GroupManager.inc");
/*-----------------------------------------------------------------*/
/**
* $Id: UserManTesting.php
* Tests the group management class
*
* Tests: - createUser() -> if username exists and if username does'nt exist
* - listUsers()
* - removeUser()
* - getUserDetails() -> if group exists and if group does'nt exist
* - getuserID() -> if username exists or doe'snt
* - addusertogroup
* - removeuserfromgroup
*
*
* @version $Revision$
* @author Mukhtar Dharsey
* @package tests.administration
*/
/*-----------------------------------------------------------------*/
$group = new groupManager;
/////////////////Test insertions
// Reload page to test if insertions fail due to existance of username
echo "<br><br>*** add new Group Test ***<br><br>";
$group->createGroup("SpellCheckers");
$group->createGroup("Publishers");
$group->createGroup("Reapers");
$group->createGroup("Politicians");
/////////////// Test list groups
echo "<br><br>*** List Groups Test ***<br><br>";
$test=$group->listGroups();
for( $i=0;$i < count($test); $i++)
{
printf("GroupNames: %s<br>", $test[$i]['name']);
}
/////////////// Test add group to unit
echo "<br><br>*** Add Group to unit Test ***<br><br>";
//test add new group to group note that 1 group can only belong to 1 unit
$test = $group->addGroupToUnit(2,1);
$test = $group->addGroupToUnit(3,2);
$test = $group->addGroupToUnit(2,3);
// test group already added
// test group already added
$test = $group->addGroupToUnit(2,1);
/////////////// Test get unit
echo "<br><br>*** Show unit group belongs to test ***<br><br>";
$test = $group->getUnit(2);
printf("unit ID: %s<br>", $test[1]['id']);
printf("unit Name: %s<br>", $test[1]['name']);
/////////////// Test get groups group belongs 2
echo "<br><br>*** Show org unit belongs to ***<br><br>";
$test = $group->getOrg(1);
printf("org ID: %s<br>", $test[1]['id']);
printf("org Name: %s<br>", $test[1]['name']);
/////////////// Test remove group from unit
echo "<br><br>*** Remove group from unit Test ***<br><br>";
$test = $group->removeGroupFromUnit(2,2);
////////////// Test Remove Group
echo "<br><br>*** Remove group Test ***<br><br>";
$test = $group->removeGroup(3);
///////////////////// Test updateGroup
echo "<br><br>*** Update Group Details/ Rename group Test ***<br><br>";
// test group not exist
$test = $group->updateGroup(4,"baboona");
// test group that does exist
$test = $group->UpdateGroup(12, "charl's glass");
//////////////// Test Get Group Name
echo "<br><br>*** Get Group Name Test ***<br><br>";
// group does'nt exist
$test = $group->GetGroupName(15);
//group does exist
$test = $group->GetGroupName(4);
printf("Name: %s<br>", $test);
/////////////// Test getGroupID
echo "<br><br>*** get GroupID Test ***<br><br>";
// group exists
$test = $group->getGroupID('System Administrators');
printf("<br>ID: %s<br>", $test);
// group doe'snt exist
$test = $group->getGroupID("Winnie Mandela");
?>
</HTML>
</BODY>