ClassTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. require_once 'Zend/Server/Reflection/Class.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_Class
  8. *
  9. * @package Zend_Server
  10. * @subpackage UnitTests
  11. * @version $Id$
  12. */
  13. class Zend_Server_Reflection_ClassTest extends PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * __construct() test
  17. *
  18. * Call as method call
  19. *
  20. * Expects:
  21. * - reflection:
  22. * - namespace: Optional;
  23. * - argv: Optional; has default;
  24. *
  25. * Returns: void
  26. */
  27. public function test__construct()
  28. {
  29. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'));
  30. $this->assertTrue($r instanceof Zend_Server_Reflection_Class);
  31. $this->assertEquals('', $r->getNamespace());
  32. $methods = $r->getMethods();
  33. $this->assertTrue(is_array($methods));
  34. foreach ($methods as $m) {
  35. $this->assertTrue($m instanceof Zend_Server_Reflection_Method);
  36. }
  37. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'), 'namespace');
  38. $this->assertEquals('namespace', $r->getNamespace());
  39. }
  40. /**
  41. * __call() test
  42. *
  43. * Call as method call
  44. *
  45. * Expects:
  46. * - method:
  47. * - args:
  48. *
  49. * Returns: mixed
  50. */
  51. public function test__call()
  52. {
  53. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'));
  54. $this->assertTrue(is_string($r->getName()));
  55. $this->assertEquals('Zend_Server_Reflection', $r->getName());
  56. }
  57. /**
  58. * test __get/set
  59. */
  60. public function testGetSet()
  61. {
  62. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'));
  63. $r->system = true;
  64. $this->assertTrue($r->system);
  65. }
  66. /**
  67. * getMethods() test
  68. *
  69. * Call as method call
  70. *
  71. * Returns: array
  72. */
  73. public function testGetMethods()
  74. {
  75. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'));
  76. $methods = $r->getMethods();
  77. $this->assertTrue(is_array($methods));
  78. foreach ($methods as $m) {
  79. $this->assertTrue($m instanceof Zend_Server_Reflection_Method);
  80. }
  81. }
  82. /**
  83. * namespace test
  84. */
  85. public function testGetNamespace()
  86. {
  87. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'));
  88. $this->assertEquals('', $r->getNamespace());
  89. $r->setNamespace('namespace');
  90. $this->assertEquals('namespace', $r->getNamespace());
  91. }
  92. /**
  93. * __wakeup() test
  94. *
  95. * Call as method call
  96. *
  97. * Returns: void
  98. */
  99. public function test__wakeup()
  100. {
  101. $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'));
  102. $s = serialize($r);
  103. $u = unserialize($s);
  104. $this->assertTrue($u instanceof Zend_Server_Reflection_Class);
  105. $this->assertEquals('', $u->getNamespace());
  106. $this->assertEquals($r->getName(), $u->getName());
  107. $rMethods = $r->getMethods();
  108. $uMethods = $r->getMethods();
  109. $this->assertEquals(count($rMethods), count($uMethods));
  110. }
  111. }