Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
bastien-phi committed Aug 4, 2017
2 parents 5178b97 + 5a64882 commit dda168d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tests/ZttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,27 @@ function post_content_can_be_sent_as_form_params()
/** @test */
function post_content_can_be_sent_as_multipart()
{
$response = Zttp::asMultipart()->post($this->url('/post'), [
$response = Zttp::asMultipart()->post($this->url('/multi-part'), [
[
'name' => 'foo',
'contents' => 'data',
'headers' => ['Z-Baz' => 'bar']
'name' => 'foo',
'contents' => 'bar'
],
]);
[
'name' => 'baz',
'contents' => 'qux',
],
[
'name' => 'test-file',
'contents' => 'test contents',
'filename' => 'test-file.txt',
],
])->json();

$this->assertEquals(['foo' => 'bar', 'baz' => 'qux'], $response['body_content']);
$this->assertTrue($response['has_file']);
$this->assertEquals($response['file_content'], 'test contents');
$this->assertStringStartsWith('multipart', $response['headers']['content-type'][0]);

$this->assertTrue($response->isOk());
$this->assertStringStartsWith('multipart', $response->json()['headers']['content-type'][0]);
}

/** @test */
Expand Down
9 changes: 9 additions & 0 deletions tests/server/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,13 @@ function build_response($request)
return response(200);
});

$app->post('/multi-part', function () {
return response()->json([
'body_content' => app('request')->only(['foo', 'baz']),
'has_file' => app('request')->hasFile('test-file'),
'file_content' => file_get_contents($_FILES['test-file']['tmp_name']),
'headers' => app('request')->header(),
], 200);
});

$app->run();

0 comments on commit dda168d

Please sign in to comment.