Closed tienvx closed 1 year ago
Translate to ffi language:
I call pactffi_with_multipart_file
3 times:
$ffi->pactffi_with_multipart_file($interaction, $ffi->InteractionPart_Request, 'text/plain', '/path/to/full_name.txt', 'full_name');
$ffi->pactffi_with_multipart_file($interaction, $ffi->InteractionPart_Request, 'image/jpeg', '/path/to/image.jpg', 'profile_image');
$ffi->pactffi_with_multipart_file($interaction, $ffi->InteractionPart_Request, 'text/plain', '/path/to/note.txt', 'personal_note');
After starting the mock server, I make a multipart request to it:
$response = $this->httpClient->post("{$this->baseUri}/user-profile", [
'multipart' => [
[
'name' => 'full_name',
'contents' => 'Zoey Turcotte',
'filename' => 'full_name.txt',
],
[
'name' => 'profile_image',
'contents' => file_get_contents(__DIR__ . '/../_resource/image.jpg'),
'filename' => 'image.jpg',
],
[
'name' => 'personal_note',
'contents' => 'testing',
'filename' => 'note.txt',
],
],
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ZmluLWFwaTphcGktc2VjcmV0',
],
]);
Mock server will start to compare the values using ContentType("x/y")
matcher:
consumer's tests failed because of mismatch when comparing 2 identical strings (
testing
!==testing
)How to reproduce:
git clone https://github.com/tienvx/pact-php.git
cd pact-php
git checkout multipart-static-files
composer install
cd example/multipart/consumer/
PACT_LOGLEVEL=trace phpunit
ContentType(\"text/plain\")
pact_matching::matchers: String -> String: comparing 'testing' to 'testing' ==> false cascaded=false matcher=ContentType("text/plain")
pact_matching::matchers: String -> String: comparing 'Colten Ziemann' to 'Zoey Turcotte' ==> false cascaded=false matcher=ContentType("text/plain")
Partial logs:
Full log: log.txt
Info:
Slack's discussion: https://pact-foundation.slack.com/archives/C02BXLDJ7JR/p1692696366946609