pact-foundation / pact-php

PHP version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project
Apache License 2.0
271 stars 92 forks source link

refactor: Add InteractionPart enum #483

Closed tienvx closed 6 months ago

tienvx commented 7 months ago

This code will be used later

Use case:

$driver->registerBody($interaction, InteractionPart::REQUEST);
$driver->registerBody($interaction, InteractionPart::RESPONSE);

public function registerBody(Interaction $interaction, InteractionPart $part): void
{
    $body = $part->isRequest() ? $interaction->getRequest()->getBody() : $interaction->getResponse()->getBody();
    ...
}
Lewiscowles1986 commented 7 months ago

This feels like it's compensating for a lack of a getBody method on interaction, which should not care if the object is a request or a response.

tienvx commented 7 months ago

Added method getBody and getHeaders to Interaction

tienvx commented 6 months ago

Ping @Lewiscowles1986 . I think you miss this one

tienvx commented 6 months ago

Thank you. If you have additional ideas please continue comment to this discussion