[42] | 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 | |
---|
| 23 | function TestDriver($aType=1,$aDir='') { |
---|
| 24 | $this->iType = $aType; |
---|
| 25 | if( $aDir == '' ) { |
---|
| 26 | $aDir = getcwd(); |
---|
| 27 | } |
---|
| 28 | if( !chdir($aDir) ) { |
---|
| 29 | die("PANIC: Can't access directory : $aDir"); |
---|
| 30 | } |
---|
| 31 | $this->iDir = $aDir; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | function GetFiles() { |
---|
| 35 | $d = @dir($this->iDir); |
---|
| 36 | $a = array(); |
---|
| 37 | while( $entry=$d->Read() ) { |
---|
| 38 | if( strstr($entry,".php") && strstr($entry,"x") && !strstr($entry,"show") && !strstr($entry,"csim") ) { |
---|
| 39 | $a[] = $entry; |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | $d->Close(); |
---|
| 43 | if( count($a) == 0 ) { |
---|
| 44 | die("PANIC: Apache/PHP does not have enough permission to read the scripts in directory: $this->iDir"); |
---|
| 45 | } |
---|
| 46 | sort($a); |
---|
| 47 | return $a; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | function GetCSIMFiles() { |
---|
| 51 | $d = @dir($this->iDir); |
---|
| 52 | $a = array(); |
---|
| 53 | while( $entry=$d->Read() ) { |
---|
| 54 | if( strstr($entry,".php") && strstr($entry,"csim") ) { |
---|
| 55 | $a[] = $entry; |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | $d->Close(); |
---|
| 59 | if( count($a) == 0 ) { |
---|
| 60 | die("PANIC: Apache/PHP does not have enough permission to read the CSIM scripts in directory: $this->iDir"); |
---|
| 61 | } |
---|
| 62 | sort($a); |
---|
| 63 | return $a; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | function Run() { |
---|
| 68 | switch( $this->iType ) { |
---|
| 69 | case 1: |
---|
| 70 | $files = $this->GetFiles(); |
---|
| 71 | break; |
---|
| 72 | case 2: |
---|
| 73 | $files = $this->GetCSIMFiles(); |
---|
| 74 | break; |
---|
| 75 | default: |
---|
| 76 | die('Panic: Unknown type of test'); |
---|
| 77 | break; |
---|
| 78 | } |
---|
| 79 | $n = count($files); |
---|
| 80 | echo "<h2>Visual test suit for JpGraph</h2>"; |
---|
| 81 | echo "Testtype: " . ($this->iType==1 ? ' Standard images ':' Image map tests '); |
---|
| 82 | echo "<br>Number of tests: $n<p>"; |
---|
| 83 | echo "<ol>"; |
---|
| 84 | |
---|
| 85 | for( $i=0; $i<$n; ++$i ) { |
---|
| 86 | if( $this->iType ==1 ) { |
---|
| 87 | echo '<li><a href="show-example.php?target='.urlencode($files[$i]).'"><img src="'.$files[$i].'" border=0 align=top></a><br><strong>Filename:</strong> <i>'.basename($files[$i])."</i>\n"; |
---|
| 88 | } |
---|
| 89 | else { |
---|
| 90 | echo '<li><a href="show-example.php?target='.urlencode($files[$i]).'">'.$files[$i]."</a>\n"; |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | echo "</ol>"; |
---|
| 94 | |
---|
| 95 | echo "<p>Done.</p>"; |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | $type=@$_GET['type']; |
---|
| 100 | if( empty($type) ) { |
---|
| 101 | $type=1; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | $driver = new TestDriver($type); |
---|
| 105 | $driver->Run(); |
---|
| 106 | |
---|
| 107 | ?> |
---|