saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.03k stars 105 forks source link

Allow partial overriding of fixtures #416

Closed innocenzi closed 2 months ago

innocenzi commented 3 months ago

So I've been using automatic fixture generation to test integration with an API that returns a lot of data.

However, I find myself duplicating some fixtures to edit some information in them so my assertions can pass depending on what I send in the request.

Instead of doing that, it would be great to have the following API:

MockClient::global([
    UpdateDealRequest::class => MockResponse::fixture('pipedrive/deal/update-16685-response', merge: [
        'status' => 'won'
    ]),
]);

The merge parameter would merge the array into the mocked response, so the following assertion would pass:

expect($response->dto())->status->toBe(Status::WON);

I am totally open to PRing that, I created the issue to avoid working on it if it was not going to be accepted 👍

innocenzi commented 3 months ago

Ended up PRing anyway since the changes were relatively simple.

Sammyjo20 commented 2 months ago

I'm going to close this as it's now a PR woo!