2
0

ParameterTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_Server
  17. * @subpackage UnitTests
  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$
  21. */
  22. require_once 'Zend/Server/Reflection/Parameter.php';
  23. require_once 'PHPUnit/Framework/TestCase.php';
  24. require_once 'PHPUnit/Framework/IncompleteTestError.php';
  25. /**
  26. * Test case for Zend_Server_Reflection_Parameter
  27. *
  28. * @category Zend
  29. * @package Zend_Server
  30. * @subpackage UnitTests
  31. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. * @group Zend_Server
  34. */
  35. class Zend_Server_Reflection_ParameterTest extends PHPUnit_Framework_TestCase
  36. {
  37. protected function _getParameter()
  38. {
  39. $method = new ReflectionMethod('Zend_Server_Reflection_Parameter', 'setType');
  40. $parameters = $method->getParameters();
  41. return $parameters[0];
  42. }
  43. /**
  44. * __construct() test
  45. *
  46. * Call as method call
  47. *
  48. * Expects:
  49. * - r:
  50. * - type: Optional; has default;
  51. * - description: Optional; has default;
  52. *
  53. * Returns: void
  54. */
  55. public function test__construct()
  56. {
  57. $parameter = $this->_getParameter();
  58. $reflection = new Zend_Server_Reflection_Parameter($parameter);
  59. $this->assertTrue($reflection instanceof Zend_Server_Reflection_Parameter);
  60. }
  61. /**
  62. * __call() test
  63. *
  64. * Call as method call
  65. *
  66. * Expects:
  67. * - method:
  68. * - args:
  69. *
  70. * Returns: mixed
  71. */
  72. public function test__call()
  73. {
  74. $r = new Zend_Server_Reflection_Parameter($this->_getParameter());
  75. // just test a few call proxies...
  76. $this->assertTrue(is_bool($r->allowsNull()));
  77. $this->assertTrue(is_bool($r->isOptional()));
  78. }
  79. /**
  80. * get/setType() test
  81. */
  82. public function testGetSetType()
  83. {
  84. $r = new Zend_Server_Reflection_Parameter($this->_getParameter());
  85. $this->assertEquals('mixed', $r->getType());
  86. $r->setType('string');
  87. $this->assertEquals('string', $r->getType());
  88. }
  89. /**
  90. * get/setDescription() test
  91. */
  92. public function testGetDescription()
  93. {
  94. $r = new Zend_Server_Reflection_Parameter($this->_getParameter());
  95. $this->assertEquals('', $r->getDescription());
  96. $r->setDescription('parameter description');
  97. $this->assertEquals('parameter description', $r->getDescription());
  98. }
  99. /**
  100. * get/setPosition() test
  101. */
  102. public function testSetPosition()
  103. {
  104. $r = new Zend_Server_Reflection_Parameter($this->_getParameter());
  105. $this->assertEquals(null, $r->getPosition());
  106. $r->setPosition(3);
  107. $this->assertEquals(3, $r->getPosition());
  108. }
  109. }