Base for a static organization website

DebugkitGroupTestCase.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * DebugKit Group Test Case
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  16. */
  17. /**
  18. * Class DebugKitGroupTestCase
  19. *
  20. */
  21. class DebugKitGroupTestCase extends PHPUnit_Framework_TestSuite {
  22. /**
  23. * Constructor
  24. */
  25. public function __construct() {
  26. $label = Inflector::humanize(Inflector::underscore(get_class($this)));
  27. parent::__construct($label);
  28. }
  29. /**
  30. * Get Test Files
  31. *
  32. * @param null $directory
  33. * @param null $excludes
  34. * @return array
  35. */
  36. public static function getTestFiles($directory = null, $excludes = null) {
  37. if (is_array($directory)) {
  38. $files = array();
  39. foreach ($directory as $d) {
  40. $files = array_merge($files, self::getTestFiles($d, $excludes));
  41. }
  42. return array_unique($files);
  43. }
  44. if ($excludes !== null) {
  45. $excludes = self::getTestFiles((array)$excludes);
  46. }
  47. if ($directory === null || $directory !== realpath($directory)) {
  48. $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
  49. $directory = str_replace(DS . DS, DS, $basePath . $directory);
  50. }
  51. $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
  52. $files = array();
  53. while ($it->valid()) {
  54. if (!$it->isDot()) {
  55. $file = $it->key();
  56. if (
  57. preg_match('|Test\.php$|', $file) &&
  58. $file !== __FILE__ &&
  59. !preg_match('|^All.+?\.php$|', basename($file)) &&
  60. ($excludes === null || !in_array($file, $excludes))
  61. ) {
  62. $files[] = $file;
  63. }
  64. }
  65. $it->next();
  66. }
  67. return $files;
  68. }
  69. }