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.
 
 
 
 
 
 

64 lines
1.2 KiB

  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * PhpUnderControl_PhalApiCUrl_Test
  5. *
  6. * 针对 ../PhalApi/CUrl.php PhalApi_CUrl 类的PHPUnit单元测试
  7. *
  8. * @author: dogstar 20150415
  9. */
  10. require_once dirname(__FILE__) . '/test_env.php';
  11. if (!class_exists('PhalApi_CUrl')) {
  12. require dirname(__FILE__) . '/../PhalApi/CUrl.php';
  13. }
  14. class PhpUnderControl_PhalApiCUrl_Test extends PHPUnit_Framework_TestCase
  15. {
  16. public $phalApiCUrl;
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. $this->phalApiCUrl = new PhalApi_CUrl(3);
  21. }
  22. protected function tearDown()
  23. {
  24. }
  25. /**
  26. * @group testGet
  27. */
  28. public function testGet()
  29. {
  30. $url = 'http://phalapi.oschina.mopaas.com/Public/demo/';
  31. $timeoutMs = 1000;
  32. $rs = $this->phalApiCUrl->get($url, $timeoutMs);
  33. //var_dump($rs);
  34. $this->assertTrue(is_string($rs));
  35. }
  36. /**
  37. * @group testPost
  38. */
  39. public function testPost()
  40. {
  41. $url = 'http://phalapi.oschina.mopaas.com/Public/demo/';
  42. $data = array('username' => 'phalapi');
  43. $timeoutMs = 1000;
  44. $rs = $this->phalApiCUrl->post($url, $data, $timeoutMs);
  45. $this->assertTrue(is_string($rs));
  46. }
  47. }