Newer
Older
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
58
59
60
61
62
63
64
<?php
class Test {
var $fails = array();
var $name = "";
var $third_party_paths = array(
'/include/JSON.php',
'/include/htmLawed.php',
'/include/PasswordHash.php',
'/include/pear/',
);
function Test() {
call_user_func_array(array($this, '__construct'), func_get_args());
}
function __construct() {
assert_options(ASSERT_CALLBACK, array($this, 'fail'));
error_reporting(E_ALL & ~E_WARNING);
}
function setup() {
}
function teardown() {
}
/*static*/ function getAllScripts() {
$root = get_osticket_root_path();
$scripts = array();
foreach (glob_recursive("$root/*.php") as $s) {
$found = false;
foreach ($this->third_party_paths as $p) {
if (strpos($s, $p) !== false) {
$found = true;
break;
}
}
if (!$found)
$scripts[] = $s;
}
return $scripts;
}
function fail($script, $line, $message) {
$this->fails[] = array(get_class($this), $script, $line, $message);
fputs(STDOUT, 'F');
}
function pass() {
fputs(STDOUT, ".");
}
function run() {
$rc = new ReflectionClass(get_class($this));
foreach ($rc->getMethods() as $m) {
if (stripos($m->name, 'test') === 0) {
$this->setup();
call_user_func(array($this, $m->name));
$this->teardown();
}
}
}
function line_number_for_offset($filename, $offset) {
$lines = file($filename);
$bytes = $line = 0;
while ($bytes < $offset) {
$bytes += strlen(array_shift($lines));
$line += 1;
}
return $line;
}