DocblockTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_CodeGenerator
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. /**
  23. * @see TestHelper
  24. */
  25. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  26. /**
  27. * @see Zend_CodeGenerator_Php_Class
  28. */
  29. require_once 'Zend/CodeGenerator/Php/Docblock.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_CodeGenerator
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. *
  37. * @group Zend_CodeGenerator
  38. * @group Zend_CodeGenerator_Php
  39. */
  40. class Zend_CodeGenerator_Php_DocblockTest extends PHPUnit_Framework_TestCase
  41. {
  42. /**
  43. * @var Zend_CodeGenerator_Php_Docblock
  44. */
  45. protected $_docblock = null;
  46. public function setup()
  47. {
  48. $this->_docblock = new Zend_CodeGenerator_Php_Docblock();
  49. }
  50. public function teardown()
  51. {
  52. $this->_docblock = null;
  53. }
  54. public function testShortDescriptionGetterAndSetter()
  55. {
  56. $this->_docblock->setShortDescription('Short Description');
  57. $this->assertEquals('Short Description', $this->_docblock->getShortDescription());
  58. }
  59. public function testLongDescriptionGetterAndSetter()
  60. {
  61. $this->_docblock->setLongDescription('Long Description');
  62. $this->assertEquals('Long Description', $this->_docblock->getLongDescription());
  63. }
  64. public function testTagGettersAndSetters()
  65. {
  66. $this->_docblock->setTag(array('name' => 'blah'));
  67. $this->_docblock->setTag(new Zend_CodeGenerator_Php_Docblock_Tag_Param(array('datatype' => 'string')));
  68. $this->_docblock->setTag(new Zend_CodeGenerator_Php_Docblock_Tag_Return(array('datatype' => 'int')));
  69. $this->assertEquals(3, count($this->_docblock->getTags()));
  70. $target = <<<EOS
  71. /**
  72. * @blah
  73. * @param string
  74. * @return int
  75. */
  76. EOS;
  77. $this->assertEquals($target, $this->_docblock->generate());
  78. }
  79. }