You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Robin Appelman
  6. * @copyright 2010 Robin Appelman icewind1991@gmailc.om
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * run all test cases
  24. */
  25. $RUNTIME_NOSETUPFS=true;
  26. require_once('../lib/base.php');
  27. OC_Util::checkAdminUser();
  28. $testCases=loadFiles(__DIR__,array('index.php','templates'));
  29. @ob_end_clean();
  30. $testResults=array();
  31. foreach($testCases as $testCaseClass){
  32. $testCase=new $testCaseClass();
  33. $results=array();
  34. foreach($testCase->getTests() as $test){
  35. $testCase->setup();
  36. try{
  37. $testCase->$test();
  38. $results[$test]='Ok';
  39. }catch(Exception $e){
  40. $results[$test]=$e->getMessage();
  41. }
  42. $testCase->tearDown();
  43. }
  44. $testResults[$testCaseClass]=$results;
  45. }
  46. $tmpl = new OC_Template( 'tests', 'index');
  47. $tmpl->assign('tests',$testResults);
  48. $tmpl->printPage();
  49. /**
  50. * recursively load all files in a folder
  51. * @param string $path
  52. * @param array $exclude list of files to exclude
  53. */
  54. function loadFiles($path,$exclude=false){
  55. $results=array();
  56. if(!$exclude){
  57. $exclude=array();
  58. }
  59. $dh=opendir($path);
  60. while($file=readdir($dh)){
  61. if($file!='.' && $file!='..' && array_search($file,$exclude)===false){
  62. if(is_file($path.'/'.$file) and substr($file,-3)=='php'){
  63. $result=require_once($path.'/'.$file);
  64. $results[]=$result;
  65. }elseif(is_dir($path.'/'.$file)){
  66. $subResults=loadFiles($path.'/'.$file);
  67. $results=array_merge($results,$subResults);
  68. }
  69. }
  70. }
  71. return $results;
  72. }
  73. ?>