Closed smakinson closed 3 years ago
@smakinson This is interesting, we purposefully bypass the login process to speed up tests, so it makes sense that the authenticate
filter isn't firing. However, testing various authentification processes is definitely a use case for this tool which honestly I had completely overlooked.
I'm not sure what the best solution is here, perhaps the ability to temporarily disable the logic we use to bypass the login might work - what are your thoughts?
cc @jasonagnew as I know you will have some good ideas for this 😄
@liamdefty by temporarily disable, are you thinking I would make a function call to disable in specific tests and then go ahead and target the login form on wp-login? Would it reenable itself in any test following? Would it reenable itself after each test? So long as I am able to have the filters run I think that should work either way.
Or perhaps (if it's possible) passing a param to the switchUser()
call to indicate doing a full process?
@smakinson I think your idea of a function call to enable it/disable it within tests sounds great!
Unfortunately I am no longer working on this project right now but I'll leave you to discuss and come up with a solution in the very capable hands of @jasonagnew
Hi @smakinson, I don't know if you're still looking for a solution for this problem but I've put together #62 to allow for some manual user switching which I think will fit with what you're trying to achieve if you want to take a look.
@ampersarnie Thanks for working on this. That sounds like it should remedy what I am interested in since it will attempt to use the regular login form and then that should cause the filter to run.
Is your feature request related to a problem? Please describe. I'm trying to add tests for a plugin and I have some code that runs in the
authenticate
filter. It seems that the filter is not run whency.switchUser
is used and a 302 is used if I attempt to usewp-login.php
to attempt a manual login. Perhaps I am missing something?Describe the solution you'd like I would like to see the normal set of actions/filters fire from a login, especially the
authenticate
filter.Describe alternatives you've considered Trying to manually log in.
Additional context Without the
authenticate
filter running, I am unable to validate the result of the code that would have run with tests.