PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Zend/Server/Reflection/ParameterTest.php

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