This commit is contained in:
thefosk
2014-01-08 18:49:23 -08:00
parent ee2ad0e1ff
commit bbdc248550
2 changed files with 64 additions and 6 deletions

View File

@@ -16,6 +16,36 @@ class UnirestTest extends UnitTestCase
$this->assertEqual("thefosk", $args->nick);
}
public function testGetWithDots()
{
$response = Unirest::get("http://httpbin.org/get", array( "Accept" => "application/json" ),
array(
"user.name" => "Mark",
"nick" => "thefosk"
));
$this->assertEqual(200, $response->code);
$args = $response->body->args;
$this->assertEqual("Mark", $args->{"user.name"});
$this->assertEqual("thefosk", $args->nick);
}
public function testGetWithDots2()
{
$response = Unirest::get("http://httpbin.org/get", array( "Accept" => "application/json" ),
array(
"user.name" => "Mark Bond",
"nick" => "thefosk"
));
$this->assertEqual(200, $response->code);
$args = $response->body->args;
$this->assertEqual("Mark+Bond", $args->{"user.name"});
$this->assertEqual("thefosk", $args->nick);
}
public function testPost()
{
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
@@ -31,6 +61,21 @@ class UnirestTest extends UnitTestCase
$this->assertEqual("thefosk", $form->nick);
}
public function testPostWithDots()
{
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
array(
"user.name" => "Mark",
"nick" => "thefosk"
));
$this->assertEqual(200, $response->code);
$form = $response->body->form;
$this->assertEqual("Mark", $form->{"user.name"});
$this->assertEqual("thefosk", $form->nick);
}
public function testUpload() {
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
array(