-
Notifications
You must be signed in to change notification settings - Fork 24.3k
PHPUnit testing named routes not working #4295
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
Conversation
I don't like the fact we have to add ``` <script> window.Laravel = {!! json_encode([ 'csrfToken' => csrf_token(), ]) !!}; </script> ``` To have it working, when the docs suggest adding only the meta tag. This will get the token from the meta tag.
Add missing IPv4/IPv6 validation messages
Update CHANGELOG.md
Simplify test suite names
Dynamic changing locale
Note that I left your dang `const` as it is, even though it's stupid. `let` for life. 💃💃💃💃
Simplify mix require
Sass compilers can sometimes be weird if import urls like this aren't quoted. They'll spit out junk like ``` Error: Encountered invalid @import syntax. ``` Anyways, pretty common practice to use quotes for all imports. I mean, seriously, how much more do you want me to write for a dang PR that adds a pair of quotes? I've got work to do, gah.
Require Laravel Mix 1.0
@alex-petrea hey, I've tried to replicate this, but I need some more info. I get 200 for each request with phpunit. I have noticed that in your question you specify different paths. the first one you are testing goes to /app/invoices and the second one is only / is that exacly what you were testing or did you test: Route::get('/app/invoices', [ and you get error not found? |
@edenreich I mistyped it. I was testing Route::get('/app/invoices', [ nevermind |
So I'm running the following test which does a post request to the login controller.
public function test_login_post()
{
$response = $this->post('/login', [
'email' => $this->user->email,
'password' => $this->user->password,
'_token' => csrf_token()
]);
dd($response);
}
Once the login is successful then the user should get redirected to the /app/invoices
If I set the /app/invoices route like this and run the test
Route::get('/app/invoices', 'InvoicesController@index')->name('account.invoices');
I get an error in the response that route('account.invoices') was not found.
If I name the route this way:
Route::get('/', [
'as' => 'account.invoices',
'uses' => 'InvoicesController@index'
]);
I get no errors.
I don't know if this is a bug or I'm doing something wrong