No Description

HttpTest.php 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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('qiniu.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('upload.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 testDelete()
  23. {
  24. $response = Client::delete('uc.qbox.me/bucketTagging', array());
  25. $this->assertEquals($response->statusCode, 401);
  26. $this->assertNotNull($response->body);
  27. $this->assertNotNull($response->error);
  28. }
  29. public function testDeleteQiniu()
  30. {
  31. $response = Client::delete('uc.qbox.me/bucketTagging', array());
  32. $this->assertEquals(401, $response->statusCode);
  33. $this->assertNotNull($response->body);
  34. $this->assertNotNull($response->xReqId());
  35. $this->assertNotNull($response->xLog());
  36. $this->assertNotNull($response->error);
  37. }
  38. public function testPost()
  39. {
  40. $response = Client::post('qiniu.com', null);
  41. $this->assertEquals($response->statusCode, 200);
  42. $this->assertNotNull($response->body);
  43. $this->assertNull($response->error);
  44. }
  45. public function testPostQiniu()
  46. {
  47. $response = Client::post('upload.qiniu.com', null);
  48. $this->assertEquals($response->statusCode, 400);
  49. $this->assertNotNull($response->body);
  50. $this->assertNotNull($response->xReqId());
  51. $this->assertNotNull($response->xLog());
  52. $this->assertNotNull($response->error);
  53. }
  54. public function testPut()
  55. {
  56. $response = Client::PUT('uc.qbox.me/bucketTagging', null);
  57. $this->assertEquals($response->statusCode, 401);
  58. $this->assertNotNull($response->body);
  59. $this->assertNotNull($response->error);
  60. }
  61. public function testPutQiniu()
  62. {
  63. $response = Client::put('uc.qbox.me/bucketTagging', null);
  64. $this->assertEquals(401, $response->statusCode);
  65. $this->assertNotNull($response->body);
  66. $this->assertNotNull($response->xReqId());
  67. $this->assertNotNull($response->xLog());
  68. $this->assertNotNull($response->error);
  69. }
  70. }