2 // vim: foldmethod=marker
\r
4 * Ethna_Plugin_Generator_Test.php
\r
6 * @author BoBpp <bobpp@users.sourceforge.jp>
\r
7 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
\r
12 // {{{ Ethna_Plugin_Generator_Test
\r
14 * Normal Test Case Generator.
\r
16 * @author BoBpp <bobpp@users.sourceforge.jp>
\r
19 class Ethna_Plugin_Generator_Test extends Ethna_Plugin_Generator
\r
25 * @param string $skelfile スケルトンファイル名
\r
26 * @param string $name テストケース名
\r
27 * @return mixed TRUE; OK
\r
28 * Ethna_Error: エラー発生
\r
30 function &generate($skelfile, $name)
\r
35 // テストを生成するディレクトリがあるか?
\r
36 // なければ app/test がデフォルト。
\r
37 $dir = $ctl->getDirectory('test');
\r
38 if ($dir === null) {
\r
39 $dir = $ctl->getDirectory('app') . "/" . "test";
\r
43 $file = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($name)) . "Test.php";
\r
44 $generatePath = "$dir/$file";
\r
47 $skelton = (!empty($skelfile))
\r
53 $macro['project_id'] = ucfirst($ctl->getAppId());
\r
54 $macro['file_path'] = $file;
\r
55 $macro['name'] = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($name));
\r
57 $userMacro = $this->_getUserMacro();
\r
58 $macro = array_merge($macro, $userMacro);
\r
61 Ethna_Util::mkdir(dirname($generatePath), 0755);
\r
62 if (file_exists($generatePath)) {
\r
63 printf("file [%s] already exists -> skip\n", $generatePath);
\r
64 } else if ($this->_generateFile($skelton, $generatePath, $macro) == false) {
\r
65 printf("[warning] file creation failed [%s]\n", $generatePath);
\r
67 printf("test script(s) successfully created [%s]\n", $generatePath);
\r