HttpTest.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Qiniu\Tests;
  3. use Qiniu\Http\Client;
  4. class HttpTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testGet()
  7. {
  8. $response = Client::get('baidu.com');
  9. $this->assertEquals($response->statusCode, 200);
  10. $this->assertNotNull($response->body);
  11. $this->assertNull($response->error);
  12. }
  13. public function testGetQiniu()
  14. {
  15. $response = Client::get('up.qiniu.com');
  16. $this->assertEquals(405, $response->statusCode);
  17. $this->assertNotNull($response->body);
  18. $this->assertNotNull($response->xReqId());
  19. $this->assertNotNull($response->xLog());
  20. $this->assertNotNull($response->error);
  21. }
  22. public function testPost()
  23. {
  24. $response = Client::post('baidu.com', null);
  25. $this->assertEquals($response->statusCode, 200);
  26. $this->assertNotNull($response->body);
  27. $this->assertNull($response->error);
  28. }
  29. public function testPostQiniu()
  30. {
  31. $response = Client::post('up.qiniu.com', null);
  32. $this->assertEquals($response->statusCode, 400);
  33. $this->assertNotNull($response->body);
  34. $this->assertNotNull($response->xReqId());
  35. $this->assertNotNull($response->xLog());
  36. $this->assertNotNull($response->error);
  37. }
  38. }