Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12345 anikendra 1
<?php
2
/**
3
 * DebugKit Group Test Case
4
 *
5
 * PHP 5
6
 *
7
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8
 * Copyright (c) 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 (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
14
 * @link          http://cakephp.org CakePHP(tm) Project
15
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
16
 */
17
 
18
/**
19
 * Class DebugKitGroupTestCase
20
 *
21
 */
22
class DebugKitGroupTestCase extends PHPUnit_Framework_TestSuite {
23
 
24
/**
25
 * Constructor
26
 */
27
	public function __construct() {
28
		$label = Inflector::humanize(Inflector::underscore(get_class($this)));
29
		parent::__construct($label);
30
	}
31
 
32
/**
33
 * Get Test Files
34
 *
35
 * @param null $directory
36
 * @param null $excludes
37
 * @return array
38
 */
39
	public static function getTestFiles($directory = null, $excludes = null) {
40
		if (is_array($directory)) {
41
			$files = array();
42
			foreach ($directory as $d) {
43
				$files = array_merge($files, self::getTestFiles($d, $excludes));
44
			}
45
			return array_unique($files);
46
		}
47
 
48
		if ($excludes !== null) {
49
			$excludes = self::getTestFiles((array)$excludes);
50
		}
51
		if ($directory === null || $directory !== realpath($directory)) {
52
			$basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
53
			$directory = str_replace(DS . DS, DS, $basePath . $directory);
54
		}
55
 
56
		$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
57
 
58
		$files = array();
59
		while ($it->valid()) {
60
 
61
			if (!$it->isDot()) {
62
				$file = $it->key();
63
 
64
				if (
65
					preg_match('|Test\.php$|', $file) &&
66
					$file !== __FILE__ &&
67
					!preg_match('|^All.+?\.php$|', basename($file)) &&
68
					($excludes === null || !in_array($file, $excludes))
69
				) {
70
					$files[] = $file;
71
				}
72
			}
73
 
74
			$it->next();
75
		}
76
 
77
		return $files;
78
	}
79
}