2 $lib_base = "../gwvplib/";
5 $WEB_ROOT_FS = realpath(dirname(__FILE__));
6 $BASE_URL = dirname($_SERVER["PHP_SELF"]);
8 global $WEB_ROOT_FS, $BASE_URL, $repo_base, $data_directory, $db_type, $db_name, $db_username, $db_password;
10 // add gwvplib as if it were a path in ../gwvplib
11 if(file_exists($lib_base)) {
12 $path = realpath($lib_base);
13 set_include_path(get_include_path().PATH_SEPARATOR.$path);
16 require_once("gwvplib.php");
17 global $db_type, $db_url;
20 $db_url = "/tmp/unittestdb.db";
22 gwvp_dbCreateSQLiteStructure("$db_url");
26 // function gwvp_createUser($email, $fullname, $password, $nick, $desc, $status)
27 // test users creation
28 gwvp_createUser("test@test.com", "test user", "password", "nick", "desc", "0");
29 gwvp_createUser("test2@test.com", "test2 user", "password", "nick2", "desc2", "0");
30 $users = gwvp_getUsers();
32 echo "\tCreate test@test.com\n";
33 if($users[0]["email"] != "test@test.com") {
34 echo "\t\tUser 0 isnt correct: ".$users[0]["email"]."\n";
36 echo "\t\tUser 0 correct\n";
38 if($users[1]["email"] != "test2@test.com") {
39 echo "\t\tUser 1 isnt correct: ".$users[0]["email"]."\n";
41 echo "\t\tUser 1 correct\n";
43 echo "\tCheck User It\n";
44 $uid1 = gwvp_getUserId("test@test.com");
45 $uid2 = gwvp_getUserId("test2@test.com");
47 echo "\t\tUser 1 id not correct\n";
49 echo "\t\tUser 1 id correct\n";
52 echo "\t\tUser 2 id not correct\n";
54 echo "\t\tUser 2 id correct\n";
57 echo "\tDelete test@test.com\n";
58 gwvp_deleteUser("test@test.com");
59 $users = gwvp_getUsers();
60 if($users[0]["email"] != "test2@test.com") {
61 echo "\t\tUser 0 isnt correct: ".$users[0]["email"]."\n";
63 echo "\t\tUser 0 is correct\n";
66 // test group creation
67 // function gwvp_createGroup($group_name, $is_admin, $owner_id)
69 echo "\tCreate testgroups\n";
70 gwvp_createGroup("testgroup", true, "1");
71 gwvp_createGroup("testgroup2", true, "1");
72 $groups = gwvp_getGroups();
73 if($groups[0]["name"] != "testgroup") {
74 echo "\t\tGroup 0 isnt correct: ".$groups[0]["name"]."\n";
76 echo "\t\tGroup 0 correct\n";
78 if($groups[1]["name"] != "testgroup2") {
79 echo "\t\tGroup 1 isnt correct: ".$groups[1]["name"]."\n";
81 echo "\t\tGroup 1 correct\n";
83 echo "\tCheck group id\n";
84 $gid1 = gwvp_getGroupId("testgroup");
85 $gid2 = gwvp_getGroupId("testgroup2");
87 echo "\t\tGroup 1 ID not correct\n";
89 echo "\t\tGroup 1 ID correct\n";
92 echo "\t\tGroup 2 ID not correct\n";
94 echo "\t\tGroup 2 ID correct\n";
97 echo "\tNow delete group\n";
98 gwvp_deleteGroup("testgroup");
99 $groups = gwvp_getGroups();
100 if($groups[0]["name"] != "testgroup2") {
101 echo "\t\tGroup 0 isnt correct: ".$groups[0]["name"]."\n";
103 echo "\t\tGroup 0 correct\n";