-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix json_decode() for php 5.2 and 5.3
- Loading branch information
Showing
2 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
<?php | ||
|
||
class RequestsTest_Response extends PHPUnit_Framework_TestCase { | ||
/** | ||
* @expectedException Requests_Exception | ||
*/ | ||
public function testInvalidJsonResponse() { | ||
$response = new Requests_Response(); | ||
$response->body = 'Invalid JSON'; | ||
$response->json(); | ||
} | ||
/** | ||
* @expectedException Requests_Exception | ||
*/ | ||
public function testInvalidJsonResponse() { | ||
$response = new Requests_Response(); | ||
$response->body = 'Invalid JSON'; | ||
$response->json(); | ||
} | ||
|
||
public function testJsonResponse() { | ||
$response = new Requests_Response(); | ||
$response->body = '{"success": false, "error": [], "data": null}'; | ||
$decodedBody = $response->json(); | ||
public function testJsonResponse() { | ||
$response = new Requests_Response(); | ||
$response->body = '{"success": false, "error": [], "data": null}'; | ||
$decodedBody = $response->json(); | ||
|
||
$expected = array( | ||
'success' => false, | ||
'error' => array(), | ||
'data' => null | ||
); | ||
$expected = array( | ||
'success' => false, | ||
'error' => array(), | ||
'data' => null | ||
); | ||
|
||
foreach($expected as $key => $value) | ||
{ | ||
$this->assertEquals($value, $decodedBody[$key]); | ||
} | ||
} | ||
foreach($expected as $key => $value) | ||
{ | ||
$this->assertEquals($value, $decodedBody[$key]); | ||
} | ||
} | ||
} |