Skip to content

Commit

Permalink
Merge pull request #32 from faustbrian/patch-2
Browse files Browse the repository at this point in the history
Add asMultipart method
  • Loading branch information
adamwathan authored Aug 4, 2017
2 parents c1c558e + 41c6b9a commit 256fb30
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Zttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ function asFormParams()
return $this->bodyFormat('form_params')->contentType('application/x-www-form-urlencoded');
}

function asMultipart()
{
return $this->bodyFormat('multipart');
}

function bodyFormat($format)
{
return tap($this, function ($request) use ($format) {
Expand Down
14 changes: 14 additions & 0 deletions tests/ZttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ function post_content_can_be_sent_as_form_params()
], $response->json());
}

/** @test */
function post_content_can_be_sent_as_multipart()
{
$response = Zttp::asMultipart()->post($this->url('/post'), [
[
'name' => 'foo',
'contents' => 'data',
'headers' => ['Z-Baz' => 'bar']
],
]);

$this->assertTrue($response->isOk());
}

/** @test */
function post_content_can_be_sent_as_json_explicitly()
{
Expand Down

0 comments on commit 256fb30

Please sign in to comment.