From 55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 10 Nov 2005 12:47:19 +0000 Subject: Initial import of prado framework --- tests/UnitTests/framework/index.php | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/UnitTests/framework/index.php (limited to 'tests/UnitTests/framework/index.php') diff --git a/tests/UnitTests/framework/index.php b/tests/UnitTests/framework/index.php new file mode 100644 index 00000000..802e979e --- /dev/null +++ b/tests/UnitTests/framework/index.php @@ -0,0 +1,100 @@ +url="$rootUri?target=".strtr(substr($path,strlen($rootPath)+1),"\\",'/'); + $this->name=basename($path); + $dir=opendir($path); + while(($entry=readdir($dir))!==false) + { + $fullpath="$path/$entry"; + if($entry!=='.' && $entry!=='..' && is_dir($fullpath)) + { + $folder=new TestFolder($fullpath,$rootPath,$rootUri); + if(!empty($folder->subFolders) || !empty($folder->testFiles)) + $this->subFolders[]=$folder; + } + else if(is_file($fullpath) && strncmp($entry,'ut',2)===0) + { + $this->testFiles[$entry]="$rootUri?target=".strtr(substr($fullpath,strlen($rootPath)+1),"\\",'/'); + } + } + closedir($dir); + } + + public function getHtml($level=0) + { + $str=str_repeat(' ',$level*4)."[ url}\">{$this->name} ]
\n"; + foreach($this->subFolders as $folder) + $str.=$folder->getHtml($level+1); + foreach($this->testFiles as $name=>$url) + $str.=str_repeat(' ',($level+1)*4)."$name
\n"; + return $str; + } +} + + +function addTests($test,$path,$recursive) +{ + $dir=opendir($path); + while(($entry=readdir($dir))!==false) + { + if(is_file($path.'/'.$entry) && strncmp($entry,'ut',2)===0) + $test->addTestFile($path.'/'.$entry); + else if($entry!=='.' && $entry!=='..' && is_dir($path.'/'.$entry) && $recursive) + addTests($test,$path.'/'.$entry,$recursive); + } + closedir($dir); +} + + +$rootPath=realpath(dirname(__FILE__)); +$rootUri=dirname($_SERVER['PHP_SELF']); + +if(isset($_GET['target'])) +{ + $target=$_GET['target']; + $recursive=true; + $fullpath=realpath("$rootPath/$target"); + if($fullpath===false || strpos($fullpath,$rootPath)!==0) + die('invalid test target'); + + require_once($rootPath.'/common.php'); + + if(is_dir($fullpath)) + { + $test=new GroupTest(basename($rootPath)."/$target"); + addTests($test,$fullpath,$recursive); + $test->run(new HtmlReporterWithCoverage(__FILE__,$rootPath)); + } + else + { + $testClass=basename($fullpath,'.php'); + require_once($fullpath); + $test=new $testClass(basename($rootPath)."/$target"); + $test->run(new HtmlReporter()); + } +} +else +{ + echo " + +utList + + + +

Prado Framework Unit Tests

+"; + $root=new TestFolder($rootPath,$rootPath,$rootUri); + echo $root->getHtml(); + echo "\n"; +} + +?> \ No newline at end of file -- cgit v1.2.3