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
|
|
@ -40,7 +40,7 @@ test('correct cache prefix is used in all contexts', function () {
|
|||
$bootstrapper = app(PrefixCacheTenancyBootstrapper::class);
|
||||
|
||||
$expectCachePrefixToBe = function (string $prefix) {
|
||||
expect($prefix . ':') // RedisStore suffixes prefix with ':'
|
||||
expect($prefix)
|
||||
->toBe(app('cache')->getPrefix())
|
||||
->toBe(app('cache.store')->getPrefix())
|
||||
->toBe(cache()->getPrefix())
|
||||
|
|
@ -72,9 +72,9 @@ test('correct cache prefix is used in all contexts', function () {
|
|||
config(['cache.prefix' => null]); // stop prefixing cache keys in central so we can provide prefix manually
|
||||
app('cache')->forgetDriver(config('cache.default'));
|
||||
|
||||
expect(cache($tenantOnePrefix . ':key'))->toBe('tenantone-value');
|
||||
expect(cache($tenantTwoPrefix . ':key'))->toBe('tenanttwo-value');
|
||||
});
|
||||
expect(cache($tenantOnePrefix . 'key'))->toBe('tenantone-value');
|
||||
expect(cache($tenantTwoPrefix . 'key'))->toBe('tenanttwo-value');
|
||||
})->skip(fn () => str(app()->version())->startsWith('10.'), 'todo@l10 drop laravel 10 support before release');
|
||||
|
||||
test('cache is persisted when reidentification is used', function () {
|
||||
$tenant1 = Tenant::create();
|
||||
|
|
@ -127,7 +127,7 @@ test('central cache is persisted', function () {
|
|||
|
||||
expect(cache()->get('key'))->toBe('central');
|
||||
expect(cache()->get('key2'))->toBe('central-two');
|
||||
|
||||
|
||||
tenancy()->initialize($tenant1);
|
||||
expect(cache()->get('key'))->toBe('tenant');
|
||||
expect(cache()->get('key2'))->toBeNull();
|
||||
|
|
@ -143,12 +143,12 @@ test('cache base prefix is customizable', function () {
|
|||
|
||||
tenancy()->initialize($tenant1);
|
||||
|
||||
expect($originalPrefix . $prefixBase . $tenant1->getTenantKey() . ':')
|
||||
expect($originalPrefix . $prefixBase . $tenant1->getTenantKey())
|
||||
->toBe(cache()->getPrefix())
|
||||
->toBe(cache()->store('redis2')->getPrefix()) // Non-default store gets prefixed correctly too
|
||||
->toBe(app('cache')->getPrefix())
|
||||
->toBe(app('cache.store')->getPrefix());
|
||||
});
|
||||
})->skip(fn () => str(app()->version())->startsWith('10.'), 'todo@l10 drop laravel 10 support before release');
|
||||
|
||||
test('cache is prefixed correctly when using a repository injected in a singleton', function () {
|
||||
$this->app->singleton(CacheService::class);
|
||||
|
|
@ -275,12 +275,12 @@ test('non default stores get prefixed too when specified in tenantCacheStores',
|
|||
tenancy()->initialize($tenant);
|
||||
|
||||
// We didn't add a prefix generator for our 'redis2' driver, so we expect the prefix to be generated using the 'default' generator
|
||||
expect($bootstrapper->generatePrefix($tenant) . ':')
|
||||
expect($bootstrapper->generatePrefix($tenant))
|
||||
->toBe(cache()->getPrefix())
|
||||
->toBe(cache()->store('redis2')->getPrefix()); // Non-default store
|
||||
|
||||
tenancy()->end();
|
||||
});
|
||||
})->skip(fn () => str(app()->version())->startsWith('10.'), 'todo@l10 drop laravel 10 support before release');
|
||||
|
||||
test('cache store prefix generation can be customized', function() {
|
||||
// Use custom prefix generator
|
||||
|
|
@ -295,14 +295,14 @@ test('cache store prefix generation can be customized', function() {
|
|||
tenancy()->initialize($tenant = Tenant::create());
|
||||
|
||||
// Expect the 'redis' store to use the prefix generated by the custom generator
|
||||
expect($customPrefixGenerator($tenant) . ':')
|
||||
expect($customPrefixGenerator($tenant))
|
||||
->toBe(cache()->getPrefix())
|
||||
->toBe(cache()->store('redis2')->getPrefix()) // Non-default cache stores specified in $tenantCacheStores are prefixed too
|
||||
->toBe(app('cache')->getPrefix())
|
||||
->toBe(app('cache.store')->getPrefix());
|
||||
|
||||
tenancy()->end();
|
||||
});
|
||||
})->skip(fn () => str(app()->version())->startsWith('10.'), 'todo@l10 drop laravel 10 support before release');
|
||||
|
||||
test('stores get prefixed using the default way if no prefix generator is specified', function() {
|
||||
$originalPrefix = config('cache.prefix');
|
||||
|
|
@ -315,10 +315,10 @@ test('stores get prefixed using the default way if no prefix generator is specif
|
|||
tenancy()->initialize($tenant);
|
||||
|
||||
// All stores use the default way of generating the prefix when the prefix generator isn't specified
|
||||
expect($defaultPrefix . ':')
|
||||
->toBe(app(PrefixCacheTenancyBootstrapper::class)->generatePrefix($tenant) . ':')
|
||||
expect($defaultPrefix)
|
||||
->toBe(app(PrefixCacheTenancyBootstrapper::class)->generatePrefix($tenant))
|
||||
->toBe(cache()->getPrefix()) // Get prefix of the default store ('redis')
|
||||
->toBe(cache()->store('redis2')->getPrefix());
|
||||
|
||||
tenancy()->end();
|
||||
});
|
||||
})->skip(fn () => str(app()->version())->startsWith('10.'), 'todo@l10 drop laravel 10 support before release');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue