JSON Decoding options
- users can now specify all the json_decode params to be used - additional method added: `Unirest\Request::defaultHeaders`
This commit is contained in:
28
tests/Unirest/ResponseTest.php
Normal file
28
tests/Unirest/ResponseTest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
class UnirestResponseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testJSONAssociativeArrays()
|
||||
{
|
||||
$opts = Unirest\Request::jsonOpts(true);
|
||||
$response = new Unirest\Response(200, '{"a":1,"b":2,"c":3,"d":4,"e":5}', '', $opts);
|
||||
|
||||
$this->assertEquals($response->body['a'], 1);
|
||||
}
|
||||
|
||||
public function testJSONAObjects()
|
||||
{
|
||||
$opts = Unirest\Request::jsonOpts(false);
|
||||
$response = new Unirest\Response(200, '{"a":1,"b":2,"c":3,"d":4,"e":5}', '', $opts);
|
||||
|
||||
$this->assertEquals($response->body->a, 1);
|
||||
}
|
||||
|
||||
public function testJSONOpts()
|
||||
{
|
||||
$opts = Unirest\Request::jsonOpts(false, 512, JSON_NUMERIC_CHECK);
|
||||
$response = new Unirest\Response(200, '{"number": 1234567890}', '', $opts);
|
||||
|
||||
$this->assertSame($response->body->number, 1234567890);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user