Closed bystro closed 6 years ago
Why not !
But I just guess we should use table notation instead of string notation, like
When I send a POST request to "/api/order/attachment-file" with files attached:
| files |
| fixtures/test-file1.png |
| fixtures/test-file2.png |
It would be more simple to use and to code !
I wonder, how to make a mixture with posting files and body using existing "I send a POST request to "echo" with body:". ?
Wnen I send a POST request to "echo" with body:
"""
{
"username" : "pablo",
"password": "money"
}
"""
with files attached:
| files |
| fixtures/test-file1.png |
| fixtures/test-file2.png |
Not sure if Behat syntax accepts it. Did you test it ?
I haven't test it yet. I'm looking for notation with only one "send request to".
It would be very ackward if I would sent it as following...
Wnen I send a POST request to "echo" with body:
"""
{
"username" : "pablo",
"password": "money"
}
"""
And When I send a POST request to "echo" with files attached:
| files |
| fixtures/test-file1.png |
| fixtures/test-file2.png |
We can consider this:
Wnen I send a POST request to "echo" with:
| body | {.........}
| files[0] | ....
| files[1] | ....
Have anyone checked if and how it is implemented at other extensions?
The only option we get I guess is to have 2 steps with a first one that push state (like headers)
@tyx could you write an example?
Given I attach files:
| files |
| fixtures/test-file1.png |
| fixtures/test-file2.png |
When I send a POST request to "echo":
"""
{
"username" : "pablo",
"password": "money"
}
"""
I'm working on the issue today.
The problem is to send payload with json and files(multipart/form-data) together. When I'm sending payload using "Content-Type: multipart/form-data; boundary=..." header, the json payload does not exists in a request body - "Wnen I send a POST request to "echo" with body:".
indeed ! And it makes sense as we should use a different content type.
I just had a look and in one app we used base_64 workaround.
I think that If files are included, json attributes should be placed in multipart/form-data body.
But a big quession is if most restful frameworks will handle this like ZendFramework does https://github.com/zendframework/zend-mvc/blob/master/src/Controller/AbstractRestfulController.php#L471
But how could you guess you add json in body without correct content type?
Fixed by #94
It seems to be useful to test requests with files included.
I use https://github.com/danielm/uploader in my projects. Dmuploader posts files to my REST API ex. /api/order/attachment-file API responses success or false information.
Very precursory scenario format ...
What do you think?