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
Specifying a specific seeder on base test class does not apply when using in-memory Sqlite DB #41863
Comments
Heya, thanks for reporting. We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as separate commits on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up. laravel new bug-report --github="--public" Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue. Thanks! |
Hi, here is the repo: https://github.com/cicnavi/bug-report with one commit https://github.com/cicnavi/bug-report/commit/023154160801cb15a67fd65f54d4b9fd6973db1e As per docs, I have added a $seeder prop in \Tests\TestCase which points to custom seeder \Database\Seeders\TestDatabaseSeeder. The test \Tests\Feature\SeedingUsingCustomSeederTest::testSampleFromTestSeederExists fails because it expects a Sample in DB which should have been seeded from custom seeder \Database\Seeders\TestDatabaseSeeder instead of default \Database\Seeders\DatabaseSeeder (as per docs). |
@cicnavi your test contains |
Sorry, I misread that. You're correct, this seems broken right now. |
Thanks for getting back to it... |
I managed to write a fix for this. Please check and test #41869. I managed to get your test passing with it. |
That was quick... Tried it out on a real project and works as expected. |
@cicnavi yeah bug fixes are merged upstream so it'll land in 9.x as well if it gets merged. |
Description:
According the docs for seeding while testing, we can specify a specific seeder on the base test class which would then be ran instead of the default Database\Seeders\DatabaseSeeder class. This does not work if in-memory SQLite DB is used.
My first thought is that this is because artisan migrate command does not accept seed class parameter (used here
framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php
Line 45 in 45de4c4
while artisan migrate:fresh command does (used here
framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php
Line 70 in 45de4c4
Is there a reason for not running aditional artisan db:seed command in \Illuminate\Foundation\Testing\RefreshDatabase::refreshInMemoryDatabase() method instead of seeding it using artisan migrate (if seeding is enabled and specific seeder is set on base test class)?
To address this I simply seed with specific seeder on my test class using $this->seed('SpecificSeeder') method.
The problem was mentioned here, however it was not addressed further.
Thank you for your valuable work...
Steps To Reproduce:
Set a specific seeder class in base test class while using in-memory Sqlite DB.
The text was updated successfully, but these errors were encountered: