Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Create assertSentInOrder to test against the order of Http Requests #35497

Closed
wants to merge 5 commits into from
Closed

Conversation

anubisthejackle
Copy link
Contributor

This adds a new assertion to the Http client: Http::assertSentInOrder which allows you to assert not only that the URLs were sent, but which order they were sent in.

Backstory: I was testing a class today that sends a series of API calls in a specific order when things are performing in one way (user doesn't exist, user is created, user is granted access to a resource). I needed to verify that these were being called in a very specific order, and it was a struggle.

I was eventually able to do it like this: https://gist.github.com/anubisthejackle/7388cca61d86c51b759eece64eb7540f

This assertion would have allowed me to simplify my test.

@GrahamCampbell GrahamCampbell changed the title Create assertSentInOrder to test against the order of Http Requests [8.x] Create assertSentInOrder to test against the order of Http Requests Dec 5, 2020
@taylorotwell
Copy link
Member

I wonder if it makes more sense to make this a bit more robust where you can pass an array of closures and not just URL strings? That way you can inspect the headers on the request as well... sometimes you may call the same URL twice but with different headers and you need to make sure those are sent in order?

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.

None yet

2 participants