web/lib/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Tool
    16  * @package    Zend_Tool
    17  * @subpackage Framework
    17  * @subpackage Framework
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: TestApplicationControllerFile.php 20096 2010-01-06 02:05:09Z bkarwin $
    20  * @version    $Id: TestApplicationControllerFile.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Tool_Project_Context_Filesystem_File
    24  * @see Zend_Tool_Project_Context_Filesystem_File
    25  */
    25  */
    31  * A profile is a hierarchical set of resources that keep track of
    31  * A profile is a hierarchical set of resources that keep track of
    32  * items within a specific project.
    32  * items within a specific project.
    33  *
    33  *
    34  * @category   Zend
    34  * @category   Zend
    35  * @package    Zend_Tool
    35  * @package    Zend_Tool
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    36  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    38  */
    38  */
    39 class Zend_Tool_Project_Context_Zf_TestApplicationControllerFile extends Zend_Tool_Project_Context_Filesystem_File
    39 class Zend_Tool_Project_Context_Zf_TestApplicationControllerFile extends Zend_Tool_Project_Context_Filesystem_File
    40 {
    40 {
    41 
    41 
    66         parent::init();
    66         parent::init();
    67         return $this;
    67         return $this;
    68     }
    68     }
    69 
    69 
    70     /**
    70     /**
       
    71      * getPersistentAttributes()
       
    72      *
       
    73      * @return unknown
       
    74      */
       
    75     public function getPersistentAttributes()
       
    76     {
       
    77         $attributes = array();
       
    78 
       
    79         if ($this->_forControllerName) {
       
    80             $attributes['forControllerName'] = $this->getForControllerName();
       
    81         }
       
    82 
       
    83         return $attributes;
       
    84     }
       
    85     
       
    86     public function getForControllerName()
       
    87     {
       
    88         return $this->_forControllerName;
       
    89     }
       
    90     
       
    91     /**
    71      * getContents()
    92      * getContents()
    72      *
    93      *
    73      * @return string
    94      * @return string
    74      */
    95      */
    75     public function getContents()
    96     public function getContents()
    76     {
    97     {
    77 
    98 
    78         $filter = new Zend_Filter_Word_DashToCamelCase();
    99         $filter = new Zend_Filter_Word_DashToCamelCase();
    79 
   100 
    80         $className = $filter->filter($this->_forControllerName) . 'ControllerTest';
   101         $className = $filter->filter($this->_forControllerName) . 'ControllerTest';
    81 
   102         
       
   103         /* @var $controllerDirectoryResource Zend_Tool_Project_Profile_Resource */
       
   104         $controllerDirectoryResource = $this->_resource->getParentResource();
       
   105         if ($controllerDirectoryResource->getParentResource()->getName() == 'TestApplicationModuleDirectory') {
       
   106             $className = $filter->filter(ucfirst($controllerDirectoryResource->getParentResource()->getForModuleName()))
       
   107                 . '_' . $className;
       
   108         }        
       
   109         
    82         $codeGenFile = new Zend_CodeGenerator_Php_File(array(
   110         $codeGenFile = new Zend_CodeGenerator_Php_File(array(
    83             'requiredFiles' => array(
       
    84                 'PHPUnit/Framework/TestCase.php'
       
    85                 ),
       
    86             'classes' => array(
   111             'classes' => array(
    87                 new Zend_CodeGenerator_Php_Class(array(
   112                 new Zend_CodeGenerator_Php_Class(array(
    88                     'name' => $className,
   113                     'name' => $className,
    89                     'extendedClass' => 'PHPUnit_Framework_TestCase',
   114                     'extendedClass' => 'Zend_Test_PHPUnit_ControllerTestCase',
    90                     'methods' => array(
   115                     'methods' => array(
    91                         new Zend_CodeGenerator_Php_Method(array(
   116                         new Zend_CodeGenerator_Php_Method(array(
    92                             'name' => 'setUp',
   117                             'name' => 'setUp',
    93                             'body' => '        /* Setup Routine */'
   118                             'body' => <<<EOS
    94                             )),
   119 \$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
    95                         new Zend_CodeGenerator_Php_Method(array(
   120 parent::setUp();
    96                             'name' => 'tearDown',
   121 EOS
    97                             'body' => '        /* Tear Down Routine */'
       
    98                             ))
   122                             ))
    99                         )
   123                         )
   100                     ))
   124                     ))
   101                 )
   125                 )
   102             ));
   126             ));