CakeTestSuite.php 1.7 KB

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