Пример #1
0
 public function testMultipartFiles()
 {
     $fixture = __DIR__ . '/fixtures/upload.txt';
     $data = array('foo' => 'bar', 'bar' => 'baz');
     $files = array('test' => $fixture);
     $body = Body::Multipart($data, $files);
     // echo $body;
     $this->assertEquals($body, array('foo' => 'bar', 'bar' => 'baz', 'test' => Body::File($fixture)));
 }
Пример #2
0
 public function testUpload()
 {
     $fixture = __DIR__ . '/../fixtures/upload.txt';
     $headers = array('Accept' => 'application/json');
     $files = array('file' => $fixture);
     $data = array('name' => 'ahmad');
     $body = Request\Body::Multipart($data, $files);
     $response = Request::post('http://mockbin.com/request', $headers, $body);
     $this->assertEquals(200, $response->code);
     $this->assertEquals('POST', $response->body->method);
     $this->assertEquals('ahmad', $response->body->postData->params->name);
     $this->assertEquals('This is a test', $response->body->postData->params->file);
 }