Source for file UnitTestCase.php

Documentation is available at UnitTestCase.php

  1. <?php
  2. /**
  3.  *  UnitTestCase.php
  4.  *
  5.  *  @author     Takuya Ookubo <sfio@sakura.ai.to>
  6.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  7.  *  @package    Ethna
  8.  *  @version    $Id: 87d7d8baaec313caaa0341f11f3e61923082571e $
  9.  */
  10.  
  11. /**
  12.  *  UnitTestCase実行クラス
  13.  *
  14.  *  @author     Takuya Ookubo <sfio@sakura.ai.to>
  15.  *  @access     public
  16.  *  @package    Ethna
  17.  */
  18. class Ethna_UnitTestCase extends UnitTestCase
  19. {
  20.     /** @var    object  Ethna_Backend       backendオブジェクト */
  21.     var $backend;
  22.  
  23.     /** @var    object  Ethna_Controller    controllerオブジェクト */
  24.     var $controller;
  25.  
  26.     /** @var    object  Ethna_Controller    controllerオブジェクト($controllerの省略形) */
  27.     var $ctl;
  28.  
  29.     /** @var    object  Ethna_Session       セッションオブジェクト */
  30.     var $session;
  31.  
  32.     /** @var    string                      アクション名 */
  33.     var $action_name;
  34.  
  35.     /** @var    object  Ethna_ActionForm    アクションフォームオブジェクト */
  36.     var $action_form;
  37.  
  38.     /** @var    object  Ethna_ActionForm    アクションフォームオブジェクト($action_formの省略形) */
  39.     var $af;
  40.  
  41.     /** @var    object  Ethna_ActionClass   アクションクラスオブジェクト */
  42.     var $action_class;
  43.  
  44.     /** @var    object  Ethna_ActionClass   アクションクラスオブジェクト($action_classの省略形) */
  45.     var $ac;
  46.  
  47.     /** @var    string                      ビュー名 */
  48.     var $forward_name;
  49.  
  50.     /** @var    object  Ethna_ViewClass     viewクラスオブジェクト */
  51.     var $view_class;
  52.  
  53.     /** @var    object  Ethna_ViewClass     viewクラスオブジェクト($view_classの省略形) */
  54.     var $vc;
  55.  
  56.     /**
  57.      *  Ethna_UnitTestCaseのコンストラクタ
  58.      *
  59.      *  @access public
  60.      *  @param  object  Ethna_Controller    $controller    コントローラオブジェクト
  61.      */
  62.     public function __construct($controller)
  63.     {
  64.         parent::__construct();
  65.  
  66.         // オブジェクトの設定
  67.         $this->controller = $controller;
  68.         $this->ctl = $this->controller;
  69.         $this->backend = $this->ctl->getBackend();
  70.         $this->session = $this->backend->getSession();
  71.  
  72.         // 変数の初期化
  73.         $this->action_form = $this->af = null;
  74.         $this->action_class = $this->ac = null;
  75.         $this->view_class = $this->vc = null;
  76.     }
  77.  
  78.     /**
  79.      *  アクションフォームの作成と関連付け
  80.      *
  81.      *  @access public
  82.      */
  83.     function _createActionForm($form_name)
  84.     {
  85.         $this->action_form = new $form_name($this->ctl);
  86.         $this->af = $this->action_form;
  87.  
  88.         // controler&backendにafを関連付け
  89.         $this->ctl->action_name = $this->action_name;
  90.         $this->ctl->action_form = $this->af;
  91.         $this->backend->action_form = $this->af;
  92.         $this->backend->af = $this->af;
  93.  
  94.         // action_error, validator の初期化
  95.         // これにより、直前のテスト結果をひきずらない
  96.         // ようにする
  97.         $ae $this->ctl->getActionError();
  98.         $ae->clear();
  99.         unset($ae->action_form);
  100.         unset($this->ctl->class_factory->object['plugin']->obj_registry["Validator"]);
  101.     }
  102.  
  103.     /**
  104.      *  アクションフォームの作成
  105.      *
  106.      *  @access public
  107.      */
  108.     function createActionForm()
  109.     {
  110.         $form_name $this->ctl->getActionFormName($this->action_name);
  111.         $this->_createActionForm($form_name);
  112.     }
  113.  
  114.     /**
  115.      *  validateOneTime()
  116.      *
  117.      *  @access public
  118.      *  @return int $result
  119.      */
  120.     function validateOneTime()
  121.     {
  122.         if ($this->af == null{
  123.             $this->createActionForm();
  124.         }
  125.  
  126.         $result $this->af->validate();
  127.         $this->af->ae->clear();
  128.  
  129.         return $result;
  130.     }
  131.  
  132.     /**
  133.      *  単純なアクションフォームの作成
  134.      *
  135.      *  @access public
  136.      */
  137.     function createPlainActionForm()
  138.     {
  139.         $form_name 'Ethna_ActionForm';
  140.         $this->_createActionForm($form_name);
  141.     }
  142.  
  143.     /**
  144.      *  アクションの作成
  145.      *
  146.      *  @access public
  147.      */
  148.     function createActionClass()
  149.     {
  150.         if ($this->af == null{
  151.             $this->createActionForm();
  152.         }
  153.  
  154.         // オブジェクト生成
  155.         $action_class_name $this->ctl->getActionClassName($this->action_name);
  156.         $this->action_class = new $action_class_name($this->backend);
  157.         $this->ac = $this->action_class;
  158.  
  159.         // backendにacを関連付け
  160.         $this->backend->action_class = $this->ac;
  161.         $this->backend->ac = $this->ac;
  162.     }
  163.  
  164.     /**
  165.      *  ビューの作成
  166.      *
  167.      *  @access public
  168.      */
  169.     function createViewClass()
  170.     {
  171.         if ($this->af == null{
  172.             $this->createPlainActionForm();
  173.         }
  174.  
  175.         // オブジェクト生成
  176.         $view_class_name $this->ctl->getViewClassName($this->forward_name);
  177.         $this->view_class = new $view_class_name($this->backend$this->forward_name$this->ctl->_getForwardPath($this->forward_name));
  178.         $this->vc = $this->view_class;
  179.     }
  180. }

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