Search code examples
phplaravelunit-testingmulti-tenant

Tenancy - Cannot declare class CreateUsersTable, because the name is already in use


Im trying to test the Tenancy functionality via PHP Unit test but there are errors coming out.

Fatal error: Cannot declare class CreateUsersTable, because the name is already in use in /var/www/database/migrations/tenant/2014_10_12_000000_create_users_table.php on line 54

I already test the migration but there is a different when running on unit test. This error only appear when creating the Tenant.

Is there a way to fix this issue?

PHP7+ Tenancy 3


Solution

  • This error occurs when doing migration and creating a tenant at the same time, so my solution is, create a migration first then do the unit testing.