Skip to content

Commit

Permalink
Allowed payload to be replaced in EndpointRequestDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p authored Oct 4, 2023
1 parent 69bf683 commit 43738a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/contracts/Input/PayloadLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function loadPayload(string $mediaType, string $format, ?string $payloadN
$content = file_get_contents($filePath);
Assert::assertNotFalse($content, "Failed to load file '$filePath' contents");

return new InputPayload($mediaType, $format, $content);
return new InputPayload($mediaType, $format, $content, "$payloadName $format");
}
}
10 changes: 9 additions & 1 deletion src/contracts/Request/Value/EndpointRequestDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
string $method,
string $uri,
?string $expectedResourceType,
?string $acceptHeader,
?string $acceptHeader = null,
array $headers = [],
?InputPayload $payload = null,
?string $name = null,
Expand Down Expand Up @@ -157,6 +157,14 @@ public function withAcceptHeader(?string $acceptHeader): self
return $endpointDefinition;
}

public function withPayload(?InputPayload $payload): self
{
$endpointDefinition = clone $this;
$endpointDefinition->payload = $payload;

return $endpointDefinition;
}

public function withSnapshotName(?string $snapshotName): self
{
$endpointDefinition = clone $this;
Expand Down

0 comments on commit 43738a7

Please sign in to comment.