This commit is contained in:
thefosk
2014-01-08 18:58:12 -08:00
parent 7ea2f5f750
commit bf865a5c30

View File

@@ -24,10 +24,10 @@ class UnirestTest extends UnitTestCase
$this->assertEqual(200, $response->code); $this->assertEqual(200, $response->code);
$args = $response->body->args; $args = $response->body->args;
print_r($args);
$this->assertEqual("Mark", $args->{"user.name"}); $this->assertEqual("value", $args->key);
$this->assertEqual("thefosk", $args->nick); $this->assertEqual("item1", $args->{"items%5B0%5D"});
$this->assertEqual("item2", $args->{"items%5B1%5D"});
} }
public function testGetWithDots() public function testGetWithDots()
@@ -93,6 +93,7 @@ class UnirestTest extends UnitTestCase
public function testUpload() { public function testUpload() {
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ), $response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
array( array(
"name" => "Mark",
"file" => "@" . dirname(__FILE__) . "/test_upload.txt" "file" => "@" . dirname(__FILE__) . "/test_upload.txt"
) )
); );
@@ -100,6 +101,9 @@ class UnirestTest extends UnitTestCase
$files = $response->body->files; $files = $response->body->files;
$this->assertEqual("This is a test", $files->file); $this->assertEqual("This is a test", $files->file);
$form = $response->body->form;
$this->assertEqual("Mark", $form->name);
} }
public function testPostMultidimensionalArray() public function testPostMultidimensionalArray()
@@ -110,6 +114,7 @@ class UnirestTest extends UnitTestCase
$this->assertEqual(200, $response->code); $this->assertEqual(200, $response->code);
$form = $response->body->form; $form = $response->body->form;
$this->assertEqual("value", $form->key);
$this->assertEqual("item1", $form->{"items[0]"}); $this->assertEqual("item1", $form->{"items[0]"});
$this->assertEqual("item2", $form->{"items[1]"}); $this->assertEqual("item2", $form->{"items[1]"});
} }