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:
20: App::uses('Folder', 'Utility');
21:
22: /**
23: * A class to contain test cases and run them with shared fixtures
24: *
25: * @package Cake.TestSuite
26: */
27: class CakeTestSuite extends PHPUnit_Framework_TestSuite {
28:
29: /**
30: * Adds all the files in a directory to the test suite. Does not recurse through directories.
31: *
32: * @param string $directory The directory to add tests from.
33: * @return void
34: */
35: public function addTestDirectory($directory = '.') {
36: $Folder = new Folder($directory);
37: list($dirs, $files) = $Folder->read(true, true, true);
38:
39: foreach ($files as $file) {
40: if (substr($file, -4) === '.php') {
41: $this->addTestFile($file);
42: }
43: }
44: }
45:
46: /**
47: * Recursively adds all the files in a directory to the test suite.
48: *
49: * @param string $directory The directory subtree to add tests from.
50: * @return void
51: */
52: public function addTestDirectoryRecursive($directory = '.') {
53: $Folder = new Folder($directory);
54: $files = $Folder->tree(null, true, 'files');
55:
56: foreach ($files as $file) {
57: if (substr($file, -4) === '.php') {
58: $this->addTestFile($file);
59: }
60: }
61: }
62:
63: }
64: