<?php error_reporting(E_ALL | E_STRICT); ini_set("track_errors", "On"); $INC = dirname(__FILE__) . "/../inc"; require_once(dirname(__FILE__) . "/config.php"); require_once($INC . "/init.inc.php"); require_once($INC . "/bug.inc.php"); require_once($INC . "/sql.inc.php"); require_once($INC . "/struct.inc.php"); require_once($INC . "/fixes.inc.php"); require_once("helpers.inc.php"); rg_log_set_file("bug.log"); require_once("common.php"); // defaults $uid = 1; $ui = array("uid" => $uid, "username" => "userX", "organization" => 0, "email" => "test@embedromix.ro", "confirmed" => 1); $repo_name = "bug-A"; rg_test_create_repo($db, $ui, $new); $data = array("bug_id" => 0, "title" => "Bug title", "body" => "This is the body\nof the\nbug. <>", "labels" => "label3,label1,label2", "state" => 1, "assigned_uid" => 6); $ri = array("repo_id" => $new['repo_id'], "name" => "repoX"); $r = rg_bug_edit($db, $ui, $ri, $data); if ($r === FALSE) { rg_log("Cannot insert a bug (" . rg_bug_error() . ")!"); exit(1); } $bug_id = $r; // verify that labels were inserted $r = rg_bug_label_get($db, $new['repo_id'], $bug_id); if ($r === FALSE) { rg_log("Cannot get labels (" . rg_bug_error() . ")!"); exit(1); } if (strcmp($r[0], "label1") != 0) { rg_log("Ordering the labels seems to not work."); exit(1); } if (strcmp($r[2], "label3") != 0) { rg_log("Ordering the labels seems to not work."); exit(1); } // add user $_u['uid'] = 0; $_u['realname'] = "user-bug-A real name"; $_u['username'] = "user-bug-A"; $_u['email'] = "rg@localhost"; $_u['pass'] = "pass1"; $_u['pass2'] = "pass1"; $_u['is_admin'] = 1; $_u['rights'] = "C"; $_u['session_time'] = 3600; $_u['confirm_token'] = ""; $_u['plan_id'] = 1000; $uid = rg_user_edit($db, $_u); if ($uid === FALSE) { rg_log("Cannot add user (" . rg_user_error() . ")!"); exit(1); } $data = array("note" => "This is just a note."); $r = rg_bug_note_add($db, $new['repo_id'], $bug_id, $uid, $data); if ($r === FALSE) { rg_log("Cannot add a note (" . rg_bug_error() . ")!"); exit(1); } $r = rg_bug_info($db, $new['repo_id'], $bug_id); if ($r['exists'] != 1) { rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!"); exit(1); } // test a non existing bug $r = rg_bug_info($db, $new['repo_id'], 0); if ($r['exists'] != 0) { rg_log("Wrong bug number (0) returned valid data!"); exit(1); } // Search bugs $q = array("reported_by" => "user-bug-A", "assigned_to" => "user-bug-A", "state" => "1", "start" => "2000-01-01", "end" => "2001-01-01", "title_string" => "IMPOSSIBLE TITLE", "body_string" => "IMPOSSIBLE BODY", "bugs_per_page" => "1"); $r = rg_bug_search($db, $new['repo_id'], $uid, $q); if ($r === FALSE) { rg_log("Cannot search bugs 1 (" . rg_bug_error() . ")!"); exit(1); } if (count($r) > 0) { rg_log("Search 1 returned a bug but the filtering should not allow it!"); exit(1); } $q = array("title_string" => "g t", "body_string" => ""); $r = rg_bug_search($db, $new['repo_id'], $uid, $q); if ($r === FALSE) { rg_log("Cannot search bugs 2 (" . rg_bug_error() . ")!"); exit(1); } if (count($r) == 0) { rg_log("Search 2 did not returned a bug we were expecting!"); exit(1); } rg_sql_close($db); rg_log("OK!"); ?>