sustained's avatar

Automatic DB seeding for tests.

On one of my projects I don't need to call $this->seed() or $this->artisan('db:seed') at all and seeding just works by default.

On another project I just started, I have to call those in setUp otherwise the DB is blank.

Both are using SQlite and :inmemory:, same version of PHP+Laravel+SQlite, same machine even.

Both are using the same base TestCase:

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication;
    use RefreshDatabase;
    // use DatabaseMigrations;
}

I don't understand.

0 likes
2 replies
D9705996's avatar

Have you looked in the migrations for the application that is automatically seeding the database? They may also be populating the database in the up method.

If not I would look at what tables are being seeded and do a full code search in your IDE to try and locate where this behaviour is coming from. I would also check you composer,json to see if there are any 3rd party packages that might be causing this.

sustained's avatar

Nah, I never seed the DB in migrations.

I'll take a look at the packages and versions between both versions.

Please or to participate in this conversation.