CakeTestSuite.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * A class to contain test cases and run them with shared fixtures
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2012, 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 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package Cake.TestSuite
  16. * @since CakePHP(tm) v 2.0
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('Folder', 'Utility');
  20. /**
  21. * A class to contain test cases and run them with shared fixtures
  22. *
  23. * @package Cake.TestSuite
  24. */
  25. class CakeTestSuite extends PHPUnit_Framework_TestSuite {
  26. /**
  27. * Adds all the files in a directory to the test suite. Does not recurse through directories.
  28. *
  29. * @param string $directory The directory to add tests from.
  30. * @return void
  31. */
  32. public function addTestDirectory($directory = '.') {
  33. $Folder = new Folder($directory);
  34. list(, $files) = $Folder->read(true, true, true);
  35. foreach ($files as $file) {
  36. if (substr($file, -4) === '.php') {
  37. $this->addTestFile($file);
  38. }
  39. }
  40. }
  41. /**
  42. * Recursively adds all the files in a directory to the test suite.
  43. *
  44. * @param string $directory The directory subtree to add tests from.
  45. * @return void
  46. */
  47. public function addTestDirectoryRecursive($directory = '.') {
  48. $Folder = new Folder($directory);
  49. $files = $Folder->tree(null, true, 'files');
  50. foreach ($files as $file) {
  51. if (substr($file, -4) === '.php') {
  52. $this->addTestFile($file);
  53. }
  54. }
  55. }
  56. }