Base for a static organization website

CakeTestSuite.php 1.7KB

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