web/lib/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Tool
       
    17  * @subpackage Framework
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    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 $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Tool_Project_Context_Filesystem_File
       
    25  */
       
    26 require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
       
    27 
       
    28 /**
       
    29  * This class is the front most class for utilizing Zend_Tool_Project
       
    30  *
       
    31  * A profile is a hierarchical set of resources that keep track of
       
    32  * items within a specific project.
       
    33  *
       
    34  * @category   Zend
       
    35  * @package    Zend_Tool
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_Tool_Project_Context_Zf_TestApplicationControllerFile extends Zend_Tool_Project_Context_Filesystem_File
       
    40 {
       
    41 
       
    42     /**
       
    43      * @var string
       
    44      */
       
    45     protected $_forControllerName = '';
       
    46 
       
    47     /**
       
    48      * getName()
       
    49      *
       
    50      * @return string
       
    51      */
       
    52     public function getName()
       
    53     {
       
    54         return 'TestApplicationControllerFile';
       
    55     }
       
    56 
       
    57     /**
       
    58      * init()
       
    59      *
       
    60      * @return Zend_Tool_Project_Context_Zf_TestApplicationControllerFile
       
    61      */
       
    62     public function init()
       
    63     {
       
    64         $this->_forControllerName = $this->_resource->getAttribute('forControllerName');
       
    65         $this->_filesystemName = ucfirst($this->_forControllerName) . 'ControllerTest.php';
       
    66         parent::init();
       
    67         return $this;
       
    68     }
       
    69 
       
    70     /**
       
    71      * getContents()
       
    72      *
       
    73      * @return string
       
    74      */
       
    75     public function getContents()
       
    76     {
       
    77 
       
    78         $filter = new Zend_Filter_Word_DashToCamelCase();
       
    79 
       
    80         $className = $filter->filter($this->_forControllerName) . 'ControllerTest';
       
    81 
       
    82         $codeGenFile = new Zend_CodeGenerator_Php_File(array(
       
    83             'requiredFiles' => array(
       
    84                 'PHPUnit/Framework/TestCase.php'
       
    85                 ),
       
    86             'classes' => array(
       
    87                 new Zend_CodeGenerator_Php_Class(array(
       
    88                     'name' => $className,
       
    89                     'extendedClass' => 'PHPUnit_Framework_TestCase',
       
    90                     'methods' => array(
       
    91                         new Zend_CodeGenerator_Php_Method(array(
       
    92                             'name' => 'setUp',
       
    93                             'body' => '        /* Setup Routine */'
       
    94                             )),
       
    95                         new Zend_CodeGenerator_Php_Method(array(
       
    96                             'name' => 'tearDown',
       
    97                             'body' => '        /* Tear Down Routine */'
       
    98                             ))
       
    99                         )
       
   100                     ))
       
   101                 )
       
   102             ));
       
   103 
       
   104         return $codeGenFile->generate();
       
   105     }
       
   106 
       
   107 }