CakeTestSuite.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.TestSuite
  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. App::uses('Folder', 'Utility');
  21. class CakeTestSuite extends PHPUnit_Framework_TestSuite {
  22. /**
  23. * Adds all the files in a directory to the test suite. Does not recurse through directories.
  24. *
  25. * @param string $directory The directory to add tests from.
  26. * @return void
  27. */
  28. public function addTestDirectory($directory = '.') {
  29. $folder = new Folder($directory);
  30. list($dirs, $files) = $folder->read(true, true, true);
  31. foreach ($files as $file) {
  32. $this->addTestFile($file);
  33. }
  34. }
  35. /**
  36. * Recursively adds all the files in a directory to the test suite.
  37. *
  38. * @param string $directory The directory subtree to add tests from.
  39. * @return void
  40. */
  41. public function addTestDirectoryRecursive($directory = '.') {
  42. $folder = new Folder($directory);
  43. $files = $folder->tree(null, false, 'files');
  44. foreach ($files as $file) {
  45. $this->addTestFile($file);
  46. }
  47. }
  48. }