mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 03:14:04 +00:00
Merge branch '2.x' into support-schema-postgres
This commit is contained in:
commit
f5f03f8097
22 changed files with 221 additions and 55 deletions
|
|
@ -18,7 +18,7 @@ class CommandsTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
config(['tenancy.migrations_directory' => database_path('../migrations')]);
|
||||
config(['tenancy.migration_paths', [database_path('../migrations')]]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
|
|||
|
|
@ -68,4 +68,20 @@ class TenantAssetTest extends TestCase
|
|||
|
||||
$this->assertSame($original, global_asset('foobar'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function asset_helper_tenancy_can_be_disabled()
|
||||
{
|
||||
$original = asset('foo');
|
||||
|
||||
config([
|
||||
'app.asset_url' => null,
|
||||
'tenancy.filesystem.asset_helper_tenancy' => false,
|
||||
]);
|
||||
|
||||
Tenant::create('foo.localhost');
|
||||
tenancy()->init('foo.localhost');
|
||||
|
||||
$this->assertSame($original, asset('foo'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,4 +121,18 @@ class TenantManagerEventsTest extends TestCase
|
|||
tenancy()->init('abc.localhost');
|
||||
$this->assertSame('tenant', \DB::connection()->getConfig()['name']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function tenant_is_persisted_before_the_created_hook_is_called()
|
||||
{
|
||||
$was_persisted = false;
|
||||
|
||||
Tenancy::eventListener('tenant.created', function ($tenancy, $tenant) use (&$was_persisted) {
|
||||
$was_persisted = $tenant->persisted;
|
||||
});
|
||||
|
||||
Tenant::new()->save();
|
||||
|
||||
$this->assertTrue($was_persisted);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -345,4 +345,38 @@ class TenantManagerTest extends TestCase
|
|||
$this->assertArrayHasKey('foo', $tenant->data);
|
||||
$this->assertArrayHasKey('abc123', $tenant->data);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function database_creation_can_be_disabled()
|
||||
{
|
||||
config(['tenancy.create_database' => false]);
|
||||
|
||||
tenancy()->hook('database.creating', function () {
|
||||
$this->fail();
|
||||
});
|
||||
|
||||
$tenant = Tenant::new()->save();
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function database_creation_can_be_disabled_for_specific_tenants()
|
||||
{
|
||||
config(['tenancy.create_database' => true]);
|
||||
|
||||
tenancy()->hook('database.creating', function () {
|
||||
$this->assertTrue(true);
|
||||
});
|
||||
|
||||
$tenant = Tenant::new()->save();
|
||||
|
||||
tenancy()->hook('database.creating', function () {
|
||||
$this->fail();
|
||||
});
|
||||
|
||||
$tenant2 = Tenant::new()->withData([
|
||||
'_tenancy_create_database' => false,
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
'tenancy.redis.tenancy' => env('TENANCY_TEST_REDIS_TENANCY', true),
|
||||
'database.redis.client' => env('TENANCY_TEST_REDIS_CLIENT', 'phpredis'),
|
||||
'tenancy.redis.prefixed_connections' => ['default'],
|
||||
'tenancy.migrations_directory' => database_path('../migrations'),
|
||||
'tenancy.migration_paths' => [database_path('../migrations')],
|
||||
'tenancy.storage_drivers.db.connection' => 'central',
|
||||
'tenancy.bootstrappers.redis' => \Stancl\Tenancy\TenancyBootstrappers\RedisTenancyBootstrapper::class,
|
||||
'queue.connections.central' => [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue