Commit d4b100ac56e2e4e2e55c8c90b81da2924e583f85

Authored by mukhtar
1 parent 027b8fa9

This handles all the group management functions unit testing


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