saloonphp / saloon

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

Feature | Add `assertSentInOrder` assertion to MockClient #400

Closed DaniTulp closed 3 months ago

DaniTulp commented 4 months ago

In Laravel there's quite a neat assertion on the Http client called assertSentInOrder, it kind of does what it says on the tin, it allows you to check that the requests that are made are sent in the same order as you expect them.

To me this opens up quite a few testing scenarios like this:

$mockClient->assertSentInOrder([
            function (FirstRequest $request) {
                // some specific assertion on the first request + type info
                return true;
            },
            function (SecondRequest $request) {
                // some specific assertion on the second request + type info
                return true;
            },
        ])
Sammyjo20 commented 3 months ago

Thanks for this PR @DaniTulp and sorry for the delay. I will be looking at this properly soon, just wanted to give you a response. I will need a little more time as I'd need to update the documentation.

DaniTulp commented 3 months ago

@Sammyjo20 no problem, let me know if you need help with that!