2
0

DocblockTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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_Reflection
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see TestHelper
  23. */
  24. require_once dirname(__FILE__) . '/../../TestHelper.php';
  25. /** requires */
  26. require_once 'Zend/Reflection/File.php';
  27. /**
  28. * @category Zend
  29. * @package Zend_Reflection
  30. * @subpackage UnitTests
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. *
  34. * @group Zend_Reflection
  35. * @group Zend_Reflection_Docblock
  36. */
  37. class Zend_Reflection_DocblockTest extends PHPUnit_Framework_TestCase
  38. {
  39. static protected $_sampleClassFileRequired = false;
  40. public function setup()
  41. {
  42. if (self::$_sampleClassFileRequired === false) {
  43. $fileToRequire = dirname(__FILE__) . '/_files/TestSampleClass.php';
  44. require_once $fileToRequire;
  45. self::$_sampleClassFileRequired = true;
  46. }
  47. }
  48. public function testDocblockShortDescription()
  49. {
  50. $classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
  51. $this->assertEquals($classReflection->getDocblock()->getShortDescription(), 'TestSampleClass5 Docblock Short Desc');
  52. }
  53. public function testDocblockLongDescription()
  54. {
  55. $classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
  56. $expectedOutput =<<<EOS
  57. This is a long description for
  58. the docblock of this class, it
  59. should be longer than 3 lines.
  60. It indeed is longer than 3 lines
  61. now.
  62. EOS;
  63. $this->assertEquals($classReflection->getDocblock()->getLongDescription(), $expectedOutput);
  64. }
  65. public function testDocblockTags()
  66. {
  67. $classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
  68. $this->assertEquals(count($classReflection->getDocblock()->getTags()), 1);
  69. $this->assertEquals(count($classReflection->getDocblock()->getTags('author')), 1);
  70. $this->assertEquals($classReflection->getDocblock()->getTag('version'), false);
  71. $this->assertEquals($classReflection->getMethod('doSomething')->getDocblock()->hasTag('return'), true);
  72. $returnTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
  73. $this->assertEquals(get_class($returnTag), 'Zend_Reflection_Docblock_Tag_Return');
  74. $this->assertEquals($returnTag->getType(), 'mixed');
  75. }
  76. public function testDocblockLines()
  77. {
  78. $classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
  79. $classDocblock = $classReflection->getDocblock();
  80. $this->assertEquals($classDocblock->getStartLine(), 76);
  81. $this->assertEquals($classDocblock->getEndLine(), 86);
  82. }
  83. public function testDocblockContents()
  84. {
  85. $classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
  86. $classDocblock = $classReflection->getDocblock();
  87. $expectedContents = <<<EOS
  88. TestSampleClass5 Docblock Short Desc
  89. This is a long description for
  90. the docblock of this class, it
  91. should be longer than 3 lines.
  92. It indeed is longer than 3 lines
  93. now.
  94. @author Ralph Schindler <ralph.schindler@zend.com>
  95. EOS;
  96. $this->assertEquals($classDocblock->getContents(), $expectedContents);
  97. }
  98. }