MethodTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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-2015 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/Method.php';
  23. require_once 'Zend/Server/Reflection.php';
  24. /**
  25. * Test case for Zend_Server_Reflection_Method
  26. *
  27. * @category Zend
  28. * @package Zend_Server
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Server
  33. */
  34. class Zend_Server_Reflection_MethodTest extends PHPUnit_Framework_TestCase
  35. {
  36. protected $_classRaw;
  37. protected $_class;
  38. protected $_method;
  39. protected function setUp()
  40. {
  41. $this->_classRaw = new ReflectionClass('Zend_Server_Reflection');
  42. $this->_method = $this->_classRaw->getMethod('reflectClass');
  43. $this->_class = new Zend_Server_Reflection_Class($this->_classRaw);
  44. }
  45. /**
  46. * __construct() test
  47. *
  48. * Call as method call
  49. *
  50. * Expects:
  51. * - class:
  52. * - r:
  53. * - namespace: Optional;
  54. * - argv: Optional; has default;
  55. *
  56. * Returns: void
  57. */
  58. public function test__construct()
  59. {
  60. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method);
  61. $this->assertTrue($r instanceof Zend_Server_Reflection_Method);
  62. $this->assertTrue($r instanceof Zend_Server_Reflection_Function_Abstract);
  63. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method, 'namespace');
  64. $this->assertEquals('namespace', $r->getNamespace());
  65. }
  66. /**
  67. * getDeclaringClass() test
  68. *
  69. * Call as method call
  70. *
  71. * Returns: Zend_Server_Reflection_Class
  72. */
  73. public function testGetDeclaringClass()
  74. {
  75. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method);
  76. $class = $r->getDeclaringClass();
  77. $this->assertTrue($class instanceof Zend_Server_Reflection_Class);
  78. $this->assertTrue($this->_class === $class);
  79. }
  80. /**
  81. * __wakeup() test
  82. *
  83. * Call as method call
  84. *
  85. * Returns: void
  86. */
  87. public function test__wakeup()
  88. {
  89. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method);
  90. $s = serialize($r);
  91. $u = unserialize($s);
  92. $this->assertTrue($u instanceof Zend_Server_Reflection_Method);
  93. $this->assertTrue($u instanceof Zend_Server_Reflection_Function_Abstract);
  94. $this->assertEquals($r->getName(), $u->getName());
  95. $this->assertEquals($r->getDeclaringClass()->getName(), $u->getDeclaringClass()->getName());
  96. }
  97. }