mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:54:05 +00:00
Update migrate:fresh test
This commit is contained in:
parent
5e76510bfb
commit
5cef50b674
1 changed files with 43 additions and 7 deletions
|
|
@ -267,7 +267,9 @@ test('run command works when sub command asks questions and accepts arguments',
|
|||
expect($user->email)->toBe('email@localhost');
|
||||
});
|
||||
|
||||
test('migrate fresh command deletes tenant databases', function() {
|
||||
test('migrate fresh command deletes tenant databases based on the tenancy.database.drop_tenant_databases_on_migrate_fresh config value', function() {
|
||||
config(['tenancy.database.drop_tenant_databases_on_migrate_fresh' => false]);
|
||||
|
||||
/** @var Tenant[] $tenants */
|
||||
$tenants = [
|
||||
Tenant::create(),
|
||||
|
|
@ -275,16 +277,50 @@ test('migrate fresh command deletes tenant databases', function() {
|
|||
Tenant::create(),
|
||||
];
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
expect($tenant->database()->manager()->databaseExists($tenant->database()->getName()))->toBeTrue();
|
||||
}
|
||||
Artisan::call('migrate:fresh', [
|
||||
'--force' => true,
|
||||
'--path' => __DIR__ . '/../assets/migrations',
|
||||
'--realpath' => true,
|
||||
]);
|
||||
|
||||
pest()->artisan('migrate:fresh');
|
||||
$tenantDatabaseExists = fn(Tenant $tenant) => $tenant->database()->manager()->databaseExists($tenant->database()->getName());
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
expect($tenant->database()->manager()->databaseExists($tenant->database()->getName()))->toBeFalse();
|
||||
expect($tenantDatabaseExists($tenant))->toBeTrue();
|
||||
}
|
||||
});
|
||||
|
||||
pest()->artisan('migrate:fresh', [
|
||||
'--force' => true,
|
||||
'--path' => __DIR__ . '/../assets/migrations',
|
||||
'--realpath' => true,
|
||||
]);
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
expect($tenantDatabaseExists($tenant))->toBeTrue();
|
||||
}
|
||||
|
||||
config(['tenancy.database.drop_tenant_databases_on_migrate_fresh' => true]);
|
||||
|
||||
$tenants = [
|
||||
Tenant::create(),
|
||||
Tenant::create(),
|
||||
Tenant::create(),
|
||||
];
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
expect($tenantDatabaseExists($tenant))->toBeTrue();
|
||||
}
|
||||
|
||||
pest()->artisan('migrate:fresh', [
|
||||
'--force' => true,
|
||||
'--path' => __DIR__ . '/../assets/migrations',
|
||||
'--realpath' => true,
|
||||
]);
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
expect($tenantDatabaseExists($tenant))->toBeFalse();
|
||||
}
|
||||
})->group('fresh');
|
||||
|
||||
// todo@tests
|
||||
function runCommandWorks(): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue