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-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:
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: $this->addTestFile($file);
41: }
42: }
43:
44: /**
45: * Recursively adds all the files in a directory to the test suite.
46: *
47: * @param string $directory The directory subtree to add tests from.
48: * @return void
49: */
50: public function addTestDirectoryRecursive($directory = '.') {
51: $Folder = new Folder($directory);
52: $files = $Folder->tree(null, false, 'files');
53:
54: foreach ($files as $file) {
55: if (strpos($file, DS . '.') !== false) {
56: continue;
57: }
58: $this->addTestFile($file);
59: }
60: }
61:
62: }
63: