1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 18:34:04 +00:00

Update dump command test

This commit is contained in:
lukinovec 2022-11-22 14:30:54 +01:00
parent 435284efc0
commit 51c30ea3dd

View file

@ -29,6 +29,10 @@ beforeEach(function () {
unlink($schemaPath); unlink($schemaPath);
} }
if (file_exists($schemaPath = database_path('tenant-schema.dump'))) {
unlink($schemaPath);
}
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) { Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
return $event->tenant; return $event->tenant;
})->toListener()); })->toListener());
@ -122,16 +126,14 @@ test('dump command works', function () {
expect($schemaPath)->toBeFile(); expect($schemaPath)->toBeFile();
}); });
test('dump command generates dump at the path specified in the tenancy migration parameters config', function() { test('dump command generates dump at the passed path', function() {
config(['tenancy.migration_parameters.--schema-path' => $schemaPath = 'tests/Etc/tenant-schema-test.dump']);
$tenant = Tenant::create(); $tenant = Tenant::create();
Artisan::call('tenants:migrate'); Artisan::call('tenants:migrate');
expect($schemaPath)->not()->toBeFile(); expect($schemaPath = 'tests/Etc/tenant-schema-test.dump')->not()->toBeFile();
Artisan::call("tenants:dump --tenant='$tenant->id'"); Artisan::call("tenants:dump --tenant='$tenant->id' --path='$schemaPath'");
expect($schemaPath)->toBeFile(); expect($schemaPath)->toBeFile();
}); });