-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[7.x] Add withToken() helper method #33075
[7.x] Add withToken() helper method #33075
Conversation
I just noticed that the I'll push an update to make this method more dynamic shortly! |
Please also rebase this PR against the latest 7.x codebase. :) |
Whoops, I think I did something wrong while rebasing! Apologies if this sent out a bunch of notifications 🤦♂️ @GrahamCampbell Sorry about this, what's the best way to fix this? Should I create a new PR and ensure my branch is on latest 7.x? |
It can be easier just copy the your commits hash sequentially (since it's not many), reset hard the branch to the latest upstream commit, cherry pick your commits and then a push force. |
Thanks @lcdss, I ended up doing something similar -- looks ok now (I think) |
The PR is now ready for review! The method changed slightly since my original message, so here's an updated snippet to demonstrate its usefulness:
Much shorter and more readable I think — hope you agree 😊 Let me know if there's any feedback! |
This PR adds a small helper method for tests using Authorization Bearer tokens as part of request headers. It was inspired by the existing
$request->bearerToken()
method on theIlluminate\Http\Request
class, which is also really useful.I feel this allows requests inside tests to read a little nicer, as well as helps against typos when writing "Authorization" and "Bearer" over and over, and instead IDEs can autocomplete the method.
There are no breaking changes, and I've added a small test to verify everything works as expected.
Happy to make changes if there's any feedback!