Adding user manager tests

skala
Julio Montoya 12 years ago
parent 5f2840a6c9
commit c8b98f1446
  1. 34
      main/inc/lib/usermanager.lib.php
  2. 378
      tests/phpunit/classes/UserManagerTest.lib.php

@ -376,23 +376,23 @@ class UserManager {
* @assert ('abc') === false
*/
public static function can_delete_user($user_id) {
global $_configuration;
if (isset($_configuration['delete_users']) && $_configuration['delete_users'] == false) {
return false;
}
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
if ($user_id != strval(intval($user_id))) return false;
if ($user_id === false) return false;
$sql = "SELECT * FROM $table_course_user WHERE status = '1' AND user_id = '".$user_id."'";
$res = Database::query($sql);
while ($course = Database::fetch_object($res)) {
$sql = "SELECT user_id FROM $table_course_user WHERE status='1' AND course_code ='".Database::escape_string($course->course_code)."'";
$res2 = Database::query($sql);
if (Database::num_rows($res2) == 1) {
return false;
}
}
return true;
global $_configuration;
if (isset($_configuration['delete_users']) && $_configuration['delete_users'] == false) {
return false;
}
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
if ($user_id != strval(intval($user_id))) return false;
if ($user_id === false) return false;
$sql = "SELECT * FROM $table_course_user WHERE status = '1' AND user_id = '".$user_id."'";
$res = Database::query($sql);
while ($course = Database::fetch_object($res)) {
$sql = "SELECT user_id FROM $table_course_user WHERE status='1' AND course_code ='".Database::escape_string($course->course_code)."'";
$res2 = Database::query($sql);
if (Database::num_rows($res2) == 1) {
return false;
}
}
return true;
}
/**

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save