PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/library/Zend/Tool/Project/Context/Zf/TestLibraryFile.php

https://gitlab.com/devtoannh/cafe
PHP | 107 lines | 44 code | 11 blank | 52 comment | 0 complexity | ac67da077879db0dd2af618b55a96a67 MD5 | raw file
  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-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: TestLibraryFile.php 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /**
  23. * @see Zend_Tool_Project_Context_Filesystem_File
  24. */
  25. require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
  26. /**
  27. * This class is the front most class for utilizing Zend_Tool_Project
  28. *
  29. * A profile is a hierarchical set of resources that keep track of
  30. * items within a specific project.
  31. *
  32. * @category Zend
  33. * @package Zend_Tool
  34. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. */
  37. class Zend_Tool_Project_Context_Zf_TestLibraryFile extends Zend_Tool_Project_Context_Filesystem_File
  38. {
  39. /**
  40. * @var string
  41. */
  42. protected $_forClassName = '';
  43. /**
  44. * getName()
  45. *
  46. * @return string
  47. */
  48. public function getName()
  49. {
  50. return 'TestLibraryFile';
  51. }
  52. /**
  53. * init()
  54. *
  55. * @return Zend_Tool_Project_Context_Zf_TestLibraryFile
  56. */
  57. public function init()
  58. {
  59. $this->_forClassName = $this->_resource->getAttribute('forClassName');
  60. $this->_filesystemName = ucfirst(ltrim(strrchr($this->_forClassName, '_'), '_')) . 'Test.php';
  61. parent::init();
  62. return $this;
  63. }
  64. /**
  65. * getContents()
  66. *
  67. * @return string
  68. */
  69. public function getContents()
  70. {
  71. $filter = new Zend_Filter_Word_DashToCamelCase();
  72. $className = $filter->filter($this->_forClassName) . 'Test';
  73. $codeGenFile = new Zend_CodeGenerator_Php_File(array(
  74. 'requiredFiles' => array(
  75. 'PHPUnit/Framework/TestCase.php'
  76. ),
  77. 'classes' => array(
  78. new Zend_CodeGenerator_Php_Class(array(
  79. 'name' => $className,
  80. 'extendedClass' => 'PHPUnit_Framework_TestCase',
  81. 'methods' => array(
  82. new Zend_CodeGenerator_Php_Method(array(
  83. 'name' => 'setUp',
  84. 'body' => ' /* Setup Routine */'
  85. )),
  86. new Zend_CodeGenerator_Php_Method(array(
  87. 'name' => 'tearDown',
  88. 'body' => ' /* Tear Down Routine */'
  89. ))
  90. )
  91. ))
  92. )
  93. ));
  94. return $codeGenFile->generate();
  95. }
  96. }