index.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ?>