mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 09:34:05 +00:00
Test schema dump file creation and usage
This commit is contained in:
parent
6327b5b417
commit
b9eb2feea0
1 changed files with 33 additions and 0 deletions
|
|
@ -120,6 +120,39 @@ test('dump command works', function () {
|
|||
expect('tests/Etc/tenant-schema-test.dump')->toBeFile();
|
||||
});
|
||||
|
||||
test('tenant dump file gets created as tenant-schema.dump in the database schema folder by default', function() {
|
||||
config(['tenancy.migration_parameters.--schema-path' => $schemaPath = database_path('schema/tenant-schema.dump')]);
|
||||
|
||||
$tenant = Tenant::create();
|
||||
Artisan::call('tenants:migrate');
|
||||
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
Artisan::call('tenants:dump');
|
||||
|
||||
expect($schemaPath)->toBeFile();
|
||||
unlink($schemaPath);
|
||||
});
|
||||
|
||||
test('migrate command uses the correct schema path by default', function () {
|
||||
config(['tenancy.migration_parameters.--schema-path' => 'tests/Etc/tenant-schema.dump']);
|
||||
$tenant = Tenant::create();
|
||||
|
||||
expect(Schema::hasTable('schema_users'))->toBeFalse();
|
||||
expect(Schema::hasTable('users'))->toBeFalse();
|
||||
|
||||
Artisan::call('tenants:migrate');
|
||||
|
||||
expect(Schema::hasTable('schema_users'))->toBeFalse();
|
||||
expect(Schema::hasTable('users'))->toBeFalse();
|
||||
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
// Check for both tables to see if missing migrations also get executed
|
||||
expect(Schema::hasTable('schema_users'))->toBeTrue();
|
||||
expect(Schema::hasTable('users'))->toBeTrue();
|
||||
});
|
||||
|
||||
test('rollback command works', function () {
|
||||
$tenant = Tenant::create();
|
||||
Artisan::call('tenants:migrate');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue