MethodTest.php 3.3 KB

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