|
@@ 30-45 (lines=16) @@
|
| 27 |
|
]; |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
public function testGet() |
| 31 |
|
{ |
| 32 |
|
$url = $this->baseUrl . '/get?a=1'; |
| 33 |
|
|
| 34 |
|
$response = JCRequest::get($url, $this->params, $this->headers); |
| 35 |
|
$this->assertEquals(200, $response->status()); |
| 36 |
|
|
| 37 |
|
$responseData = json_decode($response->body()); |
| 38 |
|
$this->assertEquals('https://httpbin.org/get?a=1&b=2&c=3', $responseData->url); |
| 39 |
|
$this->assertEquals(1, $responseData->args->a); |
| 40 |
|
$this->assertEquals(2, $responseData->args->b); |
| 41 |
|
$this->assertEquals(3, $responseData->args->c); |
| 42 |
|
|
| 43 |
|
$this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'}); |
| 44 |
|
$this->assertEquals('application/json', $responseData->headers->{'Accept'}); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
public function testPost() |
| 48 |
|
{ |
|
@@ 47-62 (lines=16) @@
|
| 44 |
|
$this->assertEquals('application/json', $responseData->headers->{'Accept'}); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
public function testPost() |
| 48 |
|
{ |
| 49 |
|
$url = $this->baseUrl . '/post?a=1'; |
| 50 |
|
|
| 51 |
|
$response = JCRequest::post($url, $this->params, $this->headers); |
| 52 |
|
$this->assertEquals(200, $response->status()); |
| 53 |
|
|
| 54 |
|
$responseData = json_decode($response->body()); |
| 55 |
|
$this->assertEquals('https://httpbin.org/post?a=1', $responseData->url); |
| 56 |
|
$this->assertEquals(1, $responseData->args->a); |
| 57 |
|
$this->assertEquals(2, $responseData->form->b); |
| 58 |
|
$this->assertEquals(3, $responseData->form->c); |
| 59 |
|
|
| 60 |
|
$this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'}); |
| 61 |
|
$this->assertEquals('application/json', $responseData->headers->{'Accept'}); |
| 62 |
|
} |
| 63 |
|
} |