2
0

MethodTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. require_once 'Zend/Server/Reflection/Method.php';
  3. require_once 'PHPUnit/Framework/TestCase.php';
  4. require_once 'PHPUnit/Framework/IncompleteTestError.php';
  5. require_once 'Zend/Server/Reflection.php';
  6. /**
  7. * Test case for Zend_Server_Reflection_Method
  8. *
  9. * @package Zend_Server
  10. * @subpackage UnitTests
  11. * @version $Id$
  12. */
  13. class Zend_Server_Reflection_MethodTest extends PHPUnit_Framework_TestCase
  14. {
  15. protected $_classRaw;
  16. protected $_class;
  17. protected $_method;
  18. protected function setUp()
  19. {
  20. $this->_classRaw = new ReflectionClass('Zend_Server_Reflection');
  21. $this->_method = $this->_classRaw->getMethod('reflectClass');
  22. $this->_class = new Zend_Server_Reflection_Class($this->_classRaw);
  23. }
  24. /**
  25. * __construct() test
  26. *
  27. * Call as method call
  28. *
  29. * Expects:
  30. * - class:
  31. * - r:
  32. * - namespace: Optional;
  33. * - argv: Optional; has default;
  34. *
  35. * Returns: void
  36. */
  37. public function test__construct()
  38. {
  39. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method);
  40. $this->assertTrue($r instanceof Zend_Server_Reflection_Method);
  41. $this->assertTrue($r instanceof Zend_Server_Reflection_Function_Abstract);
  42. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method, 'namespace');
  43. $this->assertEquals('namespace', $r->getNamespace());
  44. }
  45. /**
  46. * getDeclaringClass() test
  47. *
  48. * Call as method call
  49. *
  50. * Returns: Zend_Server_Reflection_Class
  51. */
  52. public function testGetDeclaringClass()
  53. {
  54. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method);
  55. $class = $r->getDeclaringClass();
  56. $this->assertTrue($class instanceof Zend_Server_Reflection_Class);
  57. $this->assertTrue($this->_class === $class);
  58. }
  59. /**
  60. * __wakeup() test
  61. *
  62. * Call as method call
  63. *
  64. * Returns: void
  65. */
  66. public function test__wakeup()
  67. {
  68. $r = new Zend_Server_Reflection_Method($this->_class, $this->_method);
  69. $s = serialize($r);
  70. $u = unserialize($s);
  71. $this->assertTrue($u instanceof Zend_Server_Reflection_Method);
  72. $this->assertTrue($u instanceof Zend_Server_Reflection_Function_Abstract);
  73. $this->assertEquals($r->getName(), $u->getName());
  74. $this->assertEquals($r->getDeclaringClass()->getName(), $u->getDeclaringClass()->getName());
  75. }
  76. }