-
Notifications
You must be signed in to change notification settings - Fork 327
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
creating a user and logging in with the DatabaseMigrations trait #531
Comments
Are you using a |
@staudenmeir yes. My non-dusk setup uses MySQL and Dusk uses sqlite, which is being written to when I run dusk, as mentioned above. |
Please post the SQLite connection from |
Thanks @staudenmeir. My config/database.php:
My .env.dusk.local:
And the sqlite file:
|
That's a known problem with Replace |
No.
The sqlite database is being written to, so why would changing |
Which database does your login page's controller use? |
@alexkb I'm experiencing a similar issue. Have you found a solution yet? |
@staudenmeir the login controllers are the default ones that came with laravel - there's been no customization to those. @alchermd no luck yet, but I haven't had time to try it again. Just making do with HTTP tests for now. I will try again at some point. Good to know I'm not the only one having issues. FYI - I've re-written the OP above, as I recently realised the UserFactory sets the password correctly, so there's no need to explicitly set it to 'secret'. |
Please put |
@alexkb maybe it's worth trying since I got mine to work now:
This is the only path that consistently worked for me. Other workarounds either consumes (i.e re-migrates and deletes) my main database or produce the same error as your OP. Hope it helps! EDIT: Snippets below for clarity // config/database.php
// ...
'dusk' => [
'driver' => 'sqlite',
'database' => database_path('dusk.sqlite'),
'prefix' => '',
],
// ...
|
Custom |
Oh, that's good to know. I guess using |
@staudenmeir errrr, my tests fail (same errors as the OP) when I run |
Did you check |
When using When using |
This is a great solution, can you post it in #162 and on Laracasts? |
@staudenmeir sure thing |
Gonna close this as this seems to be resolved. Thanks guys. |
Wow, this is great. Thank you @alchermd for the suggestion. Using php artisan serve --env=dusk.local fixed my issue of using the correct testing database in my test class but not using the test database when hitting the browser via dusk but since now I am forcing the env to be the dusk local it will use the testing database for the browser as well. |
Guys if you force the --env=dusk.local that's not how it should work, in docs written that it should backup current .env file, rename the env.dusk.{env} to .env and use it. But unfortunately it not do that. Once you run php artisan dusk it use the current .env file for DB connection for ex. .... |
Despite a lot of other users having issues with the initial setup of dusk, I've managed to get dusk running using
php artisan serve --quiet &
(http://localhost:8000) and then runningphp artisan dusk
. The example Browser test works fine (after changing the->assertSee('Laravel');
to my site title of course).However, as per the docs - when I move onto creating a LoginTest example, using the
DatabaseMigrations
trait, create a user and attempt to login, the authentication never finds the user. When i do a->dump()
, I see the message "These credentials do not match our records.". If I try do a query on the database (to dump the users table contents to confirm its being created) during the test, when I run the tests it just sits there and never completes.I tried what's in the documentation:
and thought that that wouldn't work, due to the password not matching.It should work because thedatabase/factories/UserFactory.php
class that comes with laravel, set's this password if you don't pass it to$user = factory(User::class)->create(
.If I open up the sqlite database, I can see the taylor user there, so it looks like it's getting created ok.
The text was updated successfully, but these errors were encountered: