Source for file ViewTest.php

Documentation is available at ViewTest.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  ViewTest.php
  5.  *
  6.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: d5be8933ca09a60faec2671fdb3ed2a6348d5814 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_ViewTest
  13. /**
  14.  *  スケルトン生成クラス
  15.  *
  16.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  ビュー用テストのスケルトンを生成する
  23.      *
  24.      *  @access public
  25.      *  @param  string  $forward_name   ビュー名
  26.      *  @param  string  $skelton        スケルトンファイル名
  27.      *  @return true|Ethna_Error       true:成功 Ethna_Error:失敗
  28.      */
  29.     function generate($forward_name$skelton null$gateway GATEWAY_WWW)
  30.     {
  31.         $view_dir $this->ctl->getViewdir();
  32.         $view_class $this->ctl->getDefaultViewClass($forward_name$gateway);
  33.         $view_path $this->ctl->getDefaultViewPath($forward_name 'Test');
  34.  
  35.         // entity
  36.         $entity $view_dir $view_path;
  37.         Ethna_Util::mkdir(dirname($entity)0755);
  38.  
  39.         // skelton
  40.         if ($skelton === null{
  41.             $skelton 'skel.view_test.php';
  42.         }
  43.  
  44.         // macro
  45.         $macro array();
  46.         $macro['project_id'$this->ctl->getAppId();
  47.         $macro['forward_name'$forward_name;
  48.         $macro['view_class'$view_class;
  49.         $macro['view_path'$view_path;
  50.  
  51.         // original view script existence check.
  52.         $original_view_path $this->ctl->getDefaultViewPath($forward_name);
  53.         $original_view_entity $view_dir $original_view_path;
  54.         if (!file_exists($original_view_entity)) {
  55.             printf("\n");
  56.             printf("[!!!!warning!!!!] original view script was not found.\n");
  57.             printf("[!!!!warning!!!!] You must generate it by the following command :\n");
  58.             printf("[!!!!warning!!!!] ethna add-view %s\n\n"$forward_name);
  59.         
  60.  
  61.         // user macro
  62.         $user_macro $this->_getUserMacro();
  63.         $macro array_merge($macro$user_macro);
  64.  
  65.  
  66.         // generate
  67.         if (file_exists($entity)) {
  68.             printf("file [%s] already exists -> skip\n"$entity);
  69.         else if ($this->_generateFile($skelton$entity$macro== false{
  70.             printf("[warning] file creation failed [%s]\n"$entity);
  71.         else {
  72.             printf("view test(s) successfully created [%s]\n"$entity);
  73.         }
  74.  
  75.         $true true;
  76.         return $true;
  77.     }
  78. }
  79. // }}}

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