1 | #!/usr/local/bin/php |
---|
2 | <?php |
---|
3 | /** |
---|
4 | * Creates new test case file from specified class file. |
---|
5 | * |
---|
6 | * @access public |
---|
7 | * @param Only argument is path to file containing class. |
---|
8 | * @author Quinn Comendant <quinn@strangecode.com> |
---|
9 | * @since 01 Dec 2005 13:56:09 |
---|
10 | */ |
---|
11 | require_once 'PHPUnit/Skeleton.php'; |
---|
12 | |
---|
13 | $dir = dirname(__FILE__) . '/../lib'; |
---|
14 | |
---|
15 | if ($_SERVER['argc'] == 2 && file_exists($dir . '/' . $_SERVER['argv'][1])) { |
---|
16 | $file = $_SERVER['argv'][1]; |
---|
17 | echo 'Proccessing ' . realpath($dir . '/' . $file) . "\n"; |
---|
18 | } else { |
---|
19 | die('First argument or file not found: ' . $_SERVER['argv'][1] . "\n"); |
---|
20 | } |
---|
21 | |
---|
22 | preg_match('/([^\.]+)\..*$/i', $file, $match); |
---|
23 | $classname = $match[1]; |
---|
24 | |
---|
25 | $ps = new PHPUnit_Skeleton($classname, '../lib/' . $file); |
---|
26 | |
---|
27 | // Generate the test class. |
---|
28 | // Default settings will not include any parent class methods, but |
---|
29 | // will include private methods. |
---|
30 | $ps->createTestClass(); |
---|
31 | |
---|
32 | // Write the new test class to file. |
---|
33 | // By default, code to run the test will be included. |
---|
34 | $ps->writeTestClass(); |
---|
35 | |
---|
36 | |
---|
37 | // $dir_handle = opendir($dir); |
---|
38 | // while ($dir_handle && ($file = readdir($dir_handle)) !== false) { |
---|
39 | // if (!preg_match('/^\./', $file) && is_file($dir . '/' . $file)) { |
---|
40 | // echo 'Proccessing ' . realpath($dir . '/' . $file) . "\n"; |
---|
41 | // |
---|
42 | // preg_match('/([^\.]+)\..*$/i', $file, $match); |
---|
43 | // $classname = $match[1]; |
---|
44 | // |
---|
45 | // $ps = new PHPUnit_Skeleton($classname, '../lib/' . $file); |
---|
46 | // |
---|
47 | // // Generate the test class. |
---|
48 | // // Default settings will not include any parent class methods, but |
---|
49 | // // will include private methods. |
---|
50 | // $ps->createTestClass(); |
---|
51 | // |
---|
52 | // // Write the new test class to file. |
---|
53 | // // By default, code to run the test will be included. |
---|
54 | // $ps->writeTestClass(); |
---|
55 | // |
---|
56 | // } |
---|
57 | // } |
---|
58 | |
---|
59 | ?> |
---|