mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
Revert BootstrapperTest changes
This commit is contained in:
parent
e5ca6eb776
commit
ba0c710e4e
1 changed files with 13 additions and 32 deletions
|
|
@ -23,7 +23,6 @@ use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\DatabaseCacheBootstrapper;
|
|
||||||
use function Stancl\Tenancy\Tests\pest;
|
use function Stancl\Tenancy\Tests\pest;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
@ -81,21 +80,12 @@ test('cache data is separated', function (string $store, string $bootstrapper) {
|
||||||
'cache.default' => $store,
|
'cache.default' => $store,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($bootstrapper === DatabaseCacheBootstrapper::class) {
|
if ($store === 'database') {
|
||||||
config(['tenancy.bootstrappers' => [DatabaseTenancyBootstrapper::class, $bootstrapper]]);
|
|
||||||
} elseif ($store === 'database') {
|
|
||||||
// Not needed with DatabaseCacheBootstrapper, as it always uses the tenant connection for tenant cache
|
|
||||||
config([
|
config([
|
||||||
'cache.stores.database.connection' => 'central',
|
'cache.stores.database.connection' => 'central',
|
||||||
'cache.stores.database.lock_connection' => 'central',
|
'cache.stores.database.lock_connection' => 'central',
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
$tenant1 = Tenant::create();
|
|
||||||
$tenant2 = Tenant::create();
|
|
||||||
|
|
||||||
if ($store === 'database') {
|
|
||||||
$createCacheTables = function () {
|
|
||||||
Schema::create('cache', function (Blueprint $table) {
|
Schema::create('cache', function (Blueprint $table) {
|
||||||
$table->string('key')->primary();
|
$table->string('key')->primary();
|
||||||
$table->mediumText('value');
|
$table->mediumText('value');
|
||||||
|
|
@ -107,18 +97,11 @@ test('cache data is separated', function (string $store, string $bootstrapper) {
|
||||||
$table->string('owner');
|
$table->string('owner');
|
||||||
$table->integer('expiration');
|
$table->integer('expiration');
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
// Create cache tables in central DB
|
|
||||||
$createCacheTables();
|
|
||||||
|
|
||||||
if ($bootstrapper === DatabaseCacheBootstrapper::class) {
|
|
||||||
// Create cache tables in tenant DBs
|
|
||||||
// With this bootstrapper, cache will be saved in these tenant DBs instead of the central DB
|
|
||||||
tenancy()->runForMultiple([$tenant1, $tenant2], $createCacheTables);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tenant1 = Tenant::create();
|
||||||
|
$tenant2 = Tenant::create();
|
||||||
|
|
||||||
cache()->set('foo', 'central');
|
cache()->set('foo', 'central');
|
||||||
expect(Cache::get('foo'))->toBe('central');
|
expect(Cache::get('foo'))->toBe('central');
|
||||||
|
|
||||||
|
|
@ -158,8 +141,6 @@ test('cache data is separated', function (string $store, string $bootstrapper) {
|
||||||
['memcached', CacheTenancyBootstrapper::class],
|
['memcached', CacheTenancyBootstrapper::class],
|
||||||
['database', CacheTenancyBootstrapper::class],
|
['database', CacheTenancyBootstrapper::class],
|
||||||
['dynamodb', CacheTenancyBootstrapper::class],
|
['dynamodb', CacheTenancyBootstrapper::class],
|
||||||
|
|
||||||
['database', DatabaseCacheBootstrapper::class],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
test('redis data is separated', function () {
|
test('redis data is separated', function () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue