mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 08:24:04 +00:00
Laravel 11 support + Docker improvements (#29)
* wip * bump jobpipeline dependency * bump pest dependency * fix composer.json syntax * minor changes to docker setup * more docker changes * compact pest output, remove unnecessary env vars from composer.json * minor pest tweaks * mssql fix * try enabling colors in CI * try setting --columns=max for pest in CI * try setting columns using env var instead of --columns in CI * Revert "try setting columns using env var instead of --columns in CI" This reverts commit eb3c177aefa97b0a3140d7f0e89c5012a854ff42. * replace --compact with --no-progress * try setting a hardcoded columns value in CI * remove --columns (doesn't work), add back --compact * try setting COLUMNS to a hardcoded value in CI * remove alternative env syntax from CI * fix PrefixCacheBootstrapperTest on L11, skip on L10 * add one more skip() call * fix validate.yml * Simplify schema dump, skip dump-related tests in L10 * Rename 'dump' table to 'example' * Bring schema dump-related tests together, add comments * Merge schema path-related tests into one, add comments * Rename dataset parameter --------- Co-authored-by: lukinovec <lukinovec@gmail.com>
This commit is contained in:
parent
d2ab2dacf2
commit
32a063b834
16 changed files with 135 additions and 178 deletions
|
|
@ -93,24 +93,6 @@ test('migrate command works with tenants option', function () {
|
|||
expect(Schema::hasTable('users'))->toBeTrue();
|
||||
});
|
||||
|
||||
test('migrate command loads schema state', function () {
|
||||
$tenant = Tenant::create();
|
||||
|
||||
expect(Schema::hasTable('schema_users'))->toBeFalse();
|
||||
expect(Schema::hasTable('users'))->toBeFalse();
|
||||
|
||||
Artisan::call('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump"');
|
||||
|
||||
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('migrate command only throws exceptions if skip-failing is not passed', function() {
|
||||
Tenant::create();
|
||||
|
||||
|
|
@ -151,6 +133,37 @@ test('migrate command does not stop after the first failure if skip-failing is p
|
|||
expect($migratedTenants)->toBe(2);
|
||||
});
|
||||
|
||||
test('the tenants migrate command uses the schema dump correctly', function (bool $schemaPathAsConfig) {
|
||||
$artisanCommand = 'tenants:migrate';
|
||||
|
||||
if ($schemaPathAsConfig) {
|
||||
// The schema dump path can be configured in 'tenancy.migration_parameters.--schema-path'
|
||||
// The tenants:migrate command will use the schema dump located at that path by default
|
||||
config(['tenancy.migration_parameters.--schema-path' => 'tests/Etc/tenant-schema.dump']);
|
||||
} else {
|
||||
// The schema dump path can be passed as an option to the tenants:migrate command
|
||||
$artisanCommand .= ' --schema-path="tests/Etc/tenant-schema.dump"';
|
||||
}
|
||||
|
||||
$tenant = Tenant::create();
|
||||
|
||||
Artisan::call($artisanCommand);
|
||||
|
||||
// 'example' is a table included in the tests/Etc/tenant-schema dump
|
||||
// 'users' is a table created by the migrations
|
||||
// The tables weren't created in the central database
|
||||
expect(Schema::hasTable('example'))->toBeFalse();
|
||||
expect(Schema::hasTable('users'))->toBeFalse();
|
||||
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
// Both the table from the schema dump and the table from actual migrations
|
||||
// Were created in the tenant database
|
||||
expect(Schema::hasTable('example'))->toBeTrue();
|
||||
expect(Schema::hasTable('users'))->toBeTrue();
|
||||
})->with([true, false])
|
||||
->skip(fn () => str(app()->version())->startsWith('10.'), 'todo@l10 drop laravel 10 support before release');
|
||||
|
||||
test('dump command works', function () {
|
||||
$tenant = Tenant::create();
|
||||
$schemaPath = 'tests/Etc/tenant-schema-test.dump';
|
||||
|
|
@ -190,26 +203,6 @@ test('dump command generates dump at the path specified in the tenancy migration
|
|||
expect($schemaPath)->toBeFile();
|
||||
});
|
||||
|
||||
test('migrate command correctly uses the schema dump located at the configured 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);
|
||||
|
||||
// schema_users is a table included in the tests/Etc/tenant-schema dump
|
||||
// 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