[8.x] Add tests for Passport::actingAs and Passport::actingAsClient #1155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently Passport is being only unit tested which is great except that each method where Laravel global helpers are being used cannot be tested at all.
This is the case with the
Passport::actingAsClient
method which uses theapp
helper to resolve and bind stuff with the container. Because of that the method wasn't tested which resulted in it being broken from July (#1040) till November (#1119). The fix was made in November but as there are still no tests for it we won't know if it breaks again in the future.This PR adds Orchestra Testbench so that we can write full functional tests with the whole framework and I've added tests for the
Passport::actingAs
andPassport::actingAsClient
methods.In doing so I had to fix the
storage_path
function conflict because now the foundationstorage_path
function exists.I've also created an abstract
PassportTestCase
class, it does a few things so that we don't need to do them in almost every test (as they are gonna be needed):passport:keys
command which generates the oauth keys (if they don't exist already) - without the keys theResourceServer
class throws an exception on instantiation and theResourceServer
is probably gonna be instantiated at some point in 95% of the functional tests.passport
driver for the auth API guard.PassportServiceProvider
without which a bunch of bindings would be missing from the container.This paves the way for further covering Passport functionality with feature/functional tests.