1
|
|
|
<?php // content="text/plain; charset=utf-8" |
2
|
|
|
//======================================================================= |
3
|
|
|
// File: TESTSUIT.PHP |
4
|
|
|
// Description: Run all the example script in current directory |
5
|
|
|
// Created: 2002-07-11 |
6
|
|
|
// Ver: $Id: testsuit.php,v 1.1.2.1 2004/03/27 12:43:07 aditus Exp $ |
7
|
|
|
// |
8
|
|
|
// License: This code is released under QPL 1.0 |
9
|
|
|
// Copyright (C) 2001,2002 Johan Persson |
10
|
|
|
//======================================================================== |
11
|
|
|
|
12
|
|
|
//------------------------------------------------------------------------- |
13
|
|
|
// |
14
|
|
|
// Usage: testsuit.php[?type=1] Generates all non image map scripts |
15
|
|
|
// testsuit.php?type=2 Generates client side image map scripts |
16
|
|
|
// |
17
|
|
|
//------------------------------------------------------------------------- |
18
|
|
|
class TestDriver |
19
|
|
|
{ |
20
|
|
|
private $iType; |
21
|
|
|
private $iDir; |
22
|
|
|
private $subFolders; |
23
|
|
|
|
24
|
|
|
public function TestDriver($aType = 1, $subFolders = []) |
25
|
|
|
{ |
26
|
|
|
$this->iType = $aType; |
27
|
|
|
|
28
|
|
|
$basePath = getcwd(); |
29
|
|
|
|
30
|
|
|
if (!chdir($basePath)) { |
31
|
|
|
die("PANIC: Can't access directory : $aDir"); |
32
|
|
|
} |
33
|
|
|
$this->iDir = $basePath; |
34
|
|
|
$this->subFolders = $subFolders; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function GetFiles() |
38
|
|
|
{ |
39
|
|
|
$d = @dir($this->iDir); |
40
|
|
|
$a = array(); |
41
|
|
|
while ($entry = $d->Read()) { |
42
|
|
|
if (strstr($entry, ".php") && strstr($entry, "x") && !strstr($entry, "show") && !strstr($entry, "csim")) { |
43
|
|
|
$a[] = $entry; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
$d->Close(); |
47
|
|
|
if (count($a) == 0) { |
48
|
|
|
die("PANIC: Apache/PHP does not have enough permission to read the scripts in directory: $this->iDir"); |
49
|
|
|
} |
50
|
|
|
sort($a); |
51
|
|
|
return $a; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function GetFilespath($path) |
55
|
|
|
{ |
56
|
|
|
$d = @dir($this->iDir); |
57
|
|
|
$a = array(); |
58
|
|
|
|
59
|
|
|
while ($entry = $d->Read()) { |
60
|
|
|
if (is_dir($entry) && $entry == $path) { |
61
|
|
|
$examplefolder = @dir($entry); |
62
|
|
|
while ($file = $examplefolder->Read()) { |
63
|
|
|
if (strstr($file, ".php") && strstr($file, "x") && !strstr($file, "show") && !strstr($file, "csim")) { |
64
|
|
|
$a[] = $entry . '/' . $file; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
$d->Close(); |
70
|
|
|
if (count($a) == 0) { |
71
|
|
|
die("PANIC: Apache/PHP does not have enough permission to read the scripts in directory: $this->iDir"); |
72
|
|
|
} |
73
|
|
|
sort($a); |
74
|
|
|
return $a; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function GetCSIMFiles() |
78
|
|
|
{ |
79
|
|
|
$d = @dir($this->iDir); |
80
|
|
|
$a = array(); |
81
|
|
|
while ($entry = $d->Read()) { |
82
|
|
|
if (strstr($entry, ".php") && strstr($entry, "csim")) { |
83
|
|
|
$a[] = $entry; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
$d->Close(); |
87
|
|
|
if (count($a) == 0) { |
88
|
|
|
die("PANIC: Apache/PHP does not have enough permission to read the CSIM scripts in directory: $this->iDir"); |
89
|
|
|
} |
90
|
|
|
sort($a); |
91
|
|
|
return $a; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function Run() |
95
|
|
|
{ |
96
|
|
|
switch ($this->iType) { |
97
|
|
|
case 1: |
98
|
|
|
$files = $this->GetFilespath($this->subFolders[0]); |
99
|
|
|
$files2 = $this->GetFilespath($this->subFolders[1]); |
100
|
|
|
break; |
101
|
|
|
case 2: |
102
|
|
|
$files = $this->GetCSIMFiles(); |
103
|
|
|
break; |
104
|
|
|
default: |
105
|
|
|
die('Panic: Unknown type of test'); |
106
|
|
|
break; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
$n = count($files); |
110
|
|
|
echo "<h2>Visual test suit for JpGraph</h2>"; |
111
|
|
|
echo "Testtype: " . ($this->iType == 1 ? ' Standard images ' : ' Image map tests '); |
112
|
|
|
echo "<br>Number of tests: $n<p>"; |
113
|
|
|
echo "<ol>"; |
114
|
|
|
|
115
|
|
|
foreach ($files as $i => $file) { |
116
|
|
|
if ($this->iType == 1) { |
117
|
|
|
echo '<li style="border:1px solid #CCC;padding:10px;">'; |
118
|
|
|
|
119
|
|
|
echo '<table>'; |
120
|
|
|
echo '<tr>'; |
121
|
|
|
echo '<td>'; |
122
|
|
|
echo '<a href="show-example.php?target=' . urlencode($files[$i]) . '">'; |
123
|
|
|
echo '<img src="' . $files[$i] . '" border=0 align=top>'; |
124
|
|
|
echo '</a>'; |
125
|
|
|
echo '</td>'; |
126
|
|
|
echo '<td>'; |
127
|
|
|
echo '<a href="show-example.php?target=' . urlencode($files2[$i]) . '">'; |
128
|
|
|
echo '<img src="' . $files2[$i] . '" border=0 align=top>'; |
129
|
|
|
echo '</a>'; |
130
|
|
|
echo '</td>'; |
131
|
|
|
echo '</tr>'; |
132
|
|
|
|
133
|
|
|
echo '<tr>'; |
134
|
|
|
echo '<td>'; |
135
|
|
|
echo '<strong>Filename:</strong> <i><a href="' . $files[$i] . '">' . basename($files[$i]) . "</a>"; |
136
|
|
|
echo '</td>'; |
137
|
|
|
echo '<td>'; |
138
|
|
|
echo '<strong>Filename:</strong> <i><a href="' . $files2[$i] . '">' . basename($files2[$i]) . "</a>"; |
139
|
|
|
echo '</td>'; |
140
|
|
|
echo '</tr>'; |
141
|
|
|
echo '</table>'; |
142
|
|
|
|
143
|
|
|
echo "</i>\n"; |
144
|
|
|
} else { |
145
|
|
|
echo '<li><a href="show-example.php?target=' . urlencode($files[$i]) . '">' . $files[$i] . "</a>\n"; |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
echo "</ol>"; |
149
|
|
|
|
150
|
|
|
echo "<p>Done.</p>"; |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
$type = @$_GET['type']; |
155
|
|
|
if (empty($type)) { |
156
|
|
|
$type = 1; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
echo '<div style="float:left">'; |
160
|
|
|
|
161
|
|
|
$driver = new TestDriver($type, ['examples_pie', 'examples_pie_jpgraph']); |
162
|
|
|
$driver->Run(); |
163
|
|
|
echo '</div>'; |
164
|
|
|
|
165
|
|
|
/* |
166
|
|
|
echo '<div style="float:left">'; |
167
|
|
|
|
168
|
|
|
$driver2 = new TestDriver($type, 'examples_pie_jpgraph'); |
169
|
|
|
$driver2->Run(); |
170
|
|
|
|
171
|
|
|
echo '</div>';*/ |
172
|
|
|
|