Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

gentests.php

Go to the documentation of this file.
00001 #!/usr/bin/php -q
00002 <?php
00003 require_once "../classes/Tests.php";
00004 $tests = new Tests();
00005 
00006 $dirs = array("common", "modules", "plugins");
00007 
00008 print "Please wait while finding tests...\n";flush();
00009 
00010 foreach ($dirs as $dir)
00011 {
00012         $d = dir($dir);
00013         print "|- $dir\n";flush();
00014         while (false !== ($e = $d->read()))
00015         {
00016                 if (is_file($d->path."/$e"))
00017                 {
00018                         print "   |- $e: ";flush();
00019                         if (preg_match('/\.php$/', $d->path."/$e"))
00020                         {
00021                                 print "OK.\n"; flush();
00022                                 $cls = substr($e, 0, -4);
00023                                 $class = parseClass($d->path."/$e");
00024                                 $tests->addTest($d->path, $e, $class);
00025                         }
00026                         else
00027                         {
00028                                 print "Not a test!\n"; flush();
00029                         }
00030                 }
00031         }
00032 }
00033 
00034 $ser = serialize($tests);
00035 $fp = fopen("tests.dat", "w");
00036 fputs($fp, $ser);
00037 fclose($fp);
00038 print "Tests are saved and ready to use!\n\n";
00039 
00040 function parseClass($file)
00041 {
00042         $src = file($file);
00043         foreach ($src as $ln => $line)
00044         {
00045                 if (preg_match('/class/', $line))
00046                 {
00047                         $m = preg_match_all('/class (.*) extends (.*)/', $line, $match);
00048                         return $match[1][0];
00049                 }
00050         }
00051 }
00052 ?>

Generated on Sun Oct 19 11:08:00 2003 for ImaComm by doxygen1.3