-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.php
More file actions
57 lines (50 loc) · 1.5 KB
/
tests.php
File metadata and controls
57 lines (50 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @param $conn
*/
function test_conn($conn) {
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
}
/**
* @param $obj
*/
function test_twshow($obj) {
// does it return a data structure
if (!is_array($obj)) {
die("An array was not returned. Response was: $obj");
}
// is the response an error message?
if (isset($obj['errors'])) {
if (strncmp("Sorry, that page does not exist.", $obj['errors'][0]['message'], 20) != 0)
die("There was an error message sent:" . $obj['errors'][0]['message'] . "\n");
}
// make sure it has the expected id that indicates everything *should be* ok
if (!isset($obj['id'])) {
die("Malformed response: id wasn't set.");
}
}
function test_twlist($obj) {
// does it return a data structure
if (!is_array($obj)) {
die("An array was not returned. Response was: $obj");
}
// is the response an error message?
if (isset($obj['errors'])) {
if (strncmp("Sorry, that page does not exist.", $obj['errors'][0]['message'], 20) != 0)
die("There was an error message sent:" . $obj['errors'][0]['message'] . "\n");
}
}
/**
* @return bool|mysqli_result
*/
function test_mysql_q($query, $conn) {
$result = mysqli_query($conn, $query);
if ($result==FALSE) {
$error = mysqli_error($conn);
if (strncmp('Duplicate',$error,5)!=0) echo "Error: " . $query . " " . mysqli_error($conn)."\n";
} else {
return $result;
}
}