Source for file AddTest.php

Documentation is available at AddTest.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  * Ethna_Plugin_Handle_AddTest.php
  5.  * 
  6.  * @author  BoBpp <bobpp@users.sourceforge.jp>
  7.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  * @package Ethna
  9.  * @version $Id: e46d848c74adad15dcfe40cf735f90659dde704c $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Handle_AddTest
  13. /**
  14.  * Ethna_Handle which generates Normal Test Case
  15.  * 
  16.  * @author BoBpp <bobpp@users.sourceforge.jp>
  17.  * @package Ethna
  18.  */
  19. {
  20.     /**
  21.      * コマンドの概要を返す
  22.      * 
  23.      * @access protected
  24.      * @return string コマンド概要
  25.      */
  26.     function getDescription()
  27.     {
  28.          return <<<EOS
  29. Create Normal UnitTestCase
  30.     (If you want action(view) test, use add-[action|view]-test):
  31.     {$this->id} [-b|--basedir=dir] [-s|--skelfile=file] [name]
  32.  
  33. EOS;
  34.     }
  35.      
  36.      /**
  37.       * コマンドの使用法を返す
  38.       * 
  39.       * @access protected
  40.       * @return string コマンドの使用方法
  41.       */
  42.     function getUsage()
  43.     {
  44.         return <<<EOS
  45. ethna {$this->id} [-b|--basedir=dir] [-s|--skelfile=file] [name]
  46.  
  47. EOS;
  48.     }
  49.      
  50.     /**
  51.      * コマンドの実装部分
  52.      * 
  53.      * テストケースファイル生成を行う
  54.      * 
  55.      * @access protected
  56.      * @return mixed 実行結果: TRUE: 成功
  57.      *                          Ethna_Error: エラー
  58.      */
  59.     function &perform()
  60.     {
  61.         // get args. 
  62.         $r $this->_getopt(array('basedir=','skelfile='));
  63.         if (Ethna::isError($r)) {
  64.             return $r;
  65.         }
  66.         list($optlist$arglist$r;
  67.         
  68.         $num count($arglist);
  69.         if ($num || $num 3{
  70.             return Ethna::raiseError("Invalid Arguments."'usage');
  71.         }
  72.         
  73.         if (isset($optlist['skelfile'])) {
  74.             $skelfile end($optlist['skelfile']);
  75.         else {
  76.             $skelfile null;
  77.         }
  78.  
  79.         $baseDir = isset($optlist['basedir']$optlist['basedir'getcwd();
  80.         $name $arglist[0];
  81.         
  82.         $r Ethna_Generator::generate(
  83.             'Test'$baseDir$skelfile$name
  84.         );
  85.         if (Ethna::isError($r)) {
  86.             return $r;
  87.         }
  88.         
  89.         $true true;
  90.         return $true;
  91.     }
  92. }
  93. // }}}

Documentation generated on Fri, 11 Nov 2011 03:57:28 +0900 by phpDocumentor 1.4.3