mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 09:04:03 +00:00
Add test for not stopping tenants:migrate after the first failure
This commit is contained in:
parent
b69c523f08
commit
146570f7e9
1 changed files with 27 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ use Stancl\Tenancy\Events\TenantCreated;
|
|||
use Stancl\Tenancy\Events\TenantDeleted;
|
||||
use Stancl\Tenancy\Tests\Etc\TestSeeder;
|
||||
use Stancl\Tenancy\Events\DeletingTenant;
|
||||
use Stancl\Tenancy\Events\DatabaseMigrated;
|
||||
use Stancl\Tenancy\Tests\Etc\ExampleSeeder;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
|
|
@ -124,6 +125,32 @@ test('migrate command only throws exceptions if skip-failing is not passed', fun
|
|||
expect(fn() => pest()->artisan('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump" --skip-failing'))->not()->toThrow(TenantDatabaseDoesNotExistException::class);
|
||||
});
|
||||
|
||||
test('migrate command does not stop after the first failure if skip-failing is passed', function() {
|
||||
$tenants = collect([
|
||||
Tenant::create(),
|
||||
$tenantWithoutDatabase = Tenant::create(),
|
||||
Tenant::create(),
|
||||
]);
|
||||
|
||||
$migratedTenants = 0;
|
||||
|
||||
Event::listen(DatabaseMigrated::class, function() use (&$migratedTenants) {
|
||||
$migratedTenants++;
|
||||
});
|
||||
|
||||
$databaseToDrop = $tenantWithoutDatabase->run(fn() => DB::connection()->getDatabaseName());
|
||||
|
||||
DB::statement("DROP DATABASE `$databaseToDrop`");
|
||||
|
||||
Artisan::call('tenants:migrate', [
|
||||
'--schema-path' => '"tests/Etc/tenant-schema.dump"',
|
||||
'--skip-failing' => true,
|
||||
'--tenants' => $tenants->pluck('id')->toArray(),
|
||||
]);
|
||||
|
||||
expect($migratedTenants)->toBe(2);
|
||||
});
|
||||
|
||||
test('dump command works', function () {
|
||||
$tenant = Tenant::create();
|
||||
Artisan::call('tenants:migrate');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue