Skip to content

Add TestCall::content() which returns marshalled payload#34

Merged
thekid merged 2 commits intomasterfrom
feature/marshalled-payload
Nov 1, 2024
Merged

Add TestCall::content() which returns marshalled payload#34
thekid merged 2 commits intomasterfrom
feature/marshalled-payload

Conversation

@thekid
Copy link
Copy Markdown
Member

@thekid thekid commented Nov 1, 2024

Example:

$fixture= new TestEndpoint([
  'POST /users' => function($call) {
    $payload= $call->content();         // (string) {"name":"Test"}
    $data= json_decode($payload, true); // (array<string, string>) ["name" => "Test"]
    return $call->respond(201, 'Created', ['Location' => '/users/'.md5($data['name'])]);
  }
]);
$fixture->resource('/users')->post(['name' => 'Test']);

@thekid
Copy link
Copy Markdown
Member Author

thekid commented Nov 1, 2024

Hrm, maybe have content() which also returns the formatted content instead?

@thekid thekid changed the title Add TestCall::payload() which returns marshalled payload Add TestCall::content() which returns marshalled payload Nov 1, 2024
@thekid thekid merged commit fad00c7 into master Nov 1, 2024
@thekid thekid deleted the feature/marshalled-payload branch November 1, 2024 14:12
@thekid
Copy link
Copy Markdown
Member Author

thekid commented Nov 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant