xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / tests / bug.php (d92ca6d810ac898d625acfd53daedd9df197d568) (1,636B) (mode 100644) [raw]
<?php
error_reporting(E_ALL | E_STRICT);
ini_set("track_errors", "On");

$INC = "../inc";
require_once($INC . "/init.inc.php");
require_once($INC . "/bug.inc.php");
require_once($INC . "/sql.inc.php");
require_once($INC . "/struct.inc.php");

rg_log_set_file("bug.log");

$rg_sql_debug = 1;

$db = rg_sql_open("dbname=trg");
if ($db === FALSE) {
	rg_log("Cannot create a database (" . rg_sql_error() . ")!");
	exit(1);
}

$r = rg_sql_struct_update($db, RG_DROP_TABLES|RG_IGNORE_ERRORS);
if ($r !== TRUE) {
	rg_log("Cannot create struct (" . rg_sql_error() . ")!");
	exit(1);
}

// defaults
$repo_id = 100;
$uid = 1;

$data = array("title" => "Bug title",
	"body" => "This is the body\nof the\nbug. <>",
	"labels" => "label1,label2,label3",
	"state" => 1,
	"assigned_uid" => 6);
$r = rg_bug_add($db, $repo_id, $uid, $data);
if ($r === FALSE) {
	rg_log("Cannot insert a bug (" . rg_bug_error() . ")!");
	exit(1);
}
$bug_id = $r;

$uid = 10;
$data = array("note" => "This is just a note.");
$r = rg_bug_note_add($db, $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, $repo_id, $bug_id);
if ($r === FALSE) {
	rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!");
	exit(1);
}
if ($r['exists'] != 1) {
	rg_log("Seems the bug does not exists!");
	exit(1);
}

// test a non existing bug
$r = rg_bug_info($db, $repo_id, 0);
if ($r === FALSE) {
	rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!");
	exit(1);
}
if ($r['exists'] != 0) {
	rg_log("Wrong bug number (0) returned valid data!");
	exit(1);
}

rg_sql_close($db);

echo "bug: OK!\n";
?>
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master