You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PhalApi_Helper_ApiDesc_Test.php 1.6 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * PhpUnderControl_PhalApiHelperApiDesc_Test
  4. *
  5. * 针对 ../../PhalApi/Helper/ApiDesc.php PhalApi_Helper_ApiDesc 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20150530
  8. */
  9. require_once dirname(__FILE__) . '/../test_env.php';
  10. DI()->loader->addDirs(dirname(__FILE__) . '/../../../Demo');
  11. if (!class_exists('PhalApi_Helper_ApiDesc')) {
  12. require dirname(__FILE__) . '/../../PhalApi/Helper/ApiDesc.php';
  13. }
  14. class PhpUnderControl_PhalApiHelperApiDesc_Test extends PHPUnit_Framework_TestCase
  15. {
  16. public $phalApiHelperApiDesc;
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. $this->phalApiHelperApiDesc = new PhalApi_Helper_ApiDesc();
  21. }
  22. protected function tearDown()
  23. {
  24. }
  25. /**
  26. * @group testRender
  27. */
  28. public function testRenderDefault()
  29. {
  30. DI()->request = new PhalApi_Request(array());
  31. $rs = $this->phalApiHelperApiDesc->render();
  32. $this->expectOutputRegex("/Default.Index/");
  33. }
  34. public function testRenderError()
  35. {
  36. DI()->request = new PhalApi_Request(array('service' => 'NoThisClass.NoThisMethod'));
  37. $rs = $this->phalApiHelperApiDesc->render();
  38. $this->expectOutputRegex("/NoThisClass.NoThisMethod/");
  39. }
  40. public function testRenderNormal()
  41. {
  42. DI()->request = new PhalApi_Request(array('service' => 'Helper_User_Mock.GetBaseInfo'));
  43. $rs = $this->phalApiHelperApiDesc->render();
  44. $this->expectOutputRegex("/Helper_User_Mock.GetBaseInfo/");
  45. }
  46. }
  47. class Api_Helper_User_Mock extends PhalApi_Api {
  48. /**
  49. * @param int user_id ID
  50. * @return int code sth...
  51. */
  52. public function getBaseInfo() {
  53. }
  54. }