[614] | 1 | #!/usr/bin/env php |
---|
[25] | 2 | <?php |
---|
| 3 | /** |
---|
[362] | 4 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 5 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[396] | 6 | * Copyright 2001-2012 Strangecode, LLC |
---|
[362] | 7 | * |
---|
| 8 | * This file is part of The Strangecode Codebase. |
---|
[25] | 9 | * |
---|
[362] | 10 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
| 11 | * modify it under the terms of the GNU General Public License as published by the |
---|
| 12 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
| 13 | * any later version. |
---|
| 14 | * |
---|
| 15 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 17 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
| 18 | * details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License along with |
---|
| 21 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
[25] | 22 | */ |
---|
[362] | 23 | |
---|
| 24 | /* |
---|
| 25 | * Creates new test case file from specified class file. |
---|
| 26 | * |
---|
| 27 | * @access public |
---|
| 28 | * @param Only argument is path to file containing class. |
---|
| 29 | * @author Quinn Comendant <quinn@strangecode.com> |
---|
| 30 | * @since 01 Dec 2005 13:56:09 |
---|
| 31 | */ |
---|
[25] | 32 | require_once 'PHPUnit/Skeleton.php'; |
---|
| 33 | |
---|
| 34 | $dir = dirname(__FILE__) . '/../lib'; |
---|
| 35 | |
---|
| 36 | if ($_SERVER['argc'] == 2 && file_exists($dir . '/' . $_SERVER['argv'][1])) { |
---|
| 37 | $file = $_SERVER['argv'][1]; |
---|
| 38 | echo 'Proccessing ' . realpath($dir . '/' . $file) . "\n"; |
---|
| 39 | } else { |
---|
| 40 | die('First argument or file not found: ' . $_SERVER['argv'][1] . "\n"); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | preg_match('/([^\.]+)\..*$/i', $file, $match); |
---|
| 44 | $classname = $match[1]; |
---|
| 45 | |
---|
| 46 | $ps = new PHPUnit_Skeleton($classname, '../lib/' . $file); |
---|
| 47 | |
---|
| 48 | // Generate the test class. |
---|
| 49 | // Default settings will not include any parent class methods, but |
---|
| 50 | // will include private methods. |
---|
| 51 | $ps->createTestClass(); |
---|
| 52 | |
---|
| 53 | // Write the new test class to file. |
---|
| 54 | // By default, code to run the test will be included. |
---|
| 55 | $ps->writeTestClass(); |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | // $dir_handle = opendir($dir); |
---|
| 59 | // while ($dir_handle && ($file = readdir($dir_handle)) !== false) { |
---|
| 60 | // if (!preg_match('/^\./', $file) && is_file($dir . '/' . $file)) { |
---|
| 61 | // echo 'Proccessing ' . realpath($dir . '/' . $file) . "\n"; |
---|
[42] | 62 | // |
---|
[25] | 63 | // preg_match('/([^\.]+)\..*$/i', $file, $match); |
---|
| 64 | // $classname = $match[1]; |
---|
[42] | 65 | // |
---|
[25] | 66 | // $ps = new PHPUnit_Skeleton($classname, '../lib/' . $file); |
---|
[42] | 67 | // |
---|
[25] | 68 | // // Generate the test class. |
---|
| 69 | // // Default settings will not include any parent class methods, but |
---|
| 70 | // // will include private methods. |
---|
| 71 | // $ps->createTestClass(); |
---|
[42] | 72 | // |
---|
[25] | 73 | // // Write the new test class to file. |
---|
| 74 | // // By default, code to run the test will be included. |
---|
| 75 | // $ps->writeTestClass(); |
---|
[42] | 76 | // |
---|
[25] | 77 | // } |
---|
| 78 | // } |
---|
| 79 | |
---|