Skip to content

More examples #14

@oxodao

Description

@oxodao

Hi!

I've seen this issue being closed while there are still quite a few places in the docs that do not have examples
#3

Do you plan to add those ?

Particularly, I took quite a while to figure out how to test multi-part forms that contains file, as I was trying to use the withBody method combined with a MultipartStream object.

My final solution here is the following, if anyone have the same needs:

$filepath = dirname(__FILE__) . '/../assets/asset1.jpg';
$this->guzzler
    ->expects($this->once())
    ->post('/assets/')
    ->withHeader('Authorization', 'Bearer ' . $this->fakeToken)
    ->withForm([
          'my_field_1' => 1,
          'my_field_2' => 'my_value',
     ])
     ->withFile('file', new File(Utils::tryFopen($filepath, 'r')))
     ->willRespond(new Response(409, [], ''));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions