1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:34:04 +00:00

Create MySQL/PostgreSQL DBs while using sqlite as the central DB driver

This commit is contained in:
Samuel Štancl 2019-09-21 11:11:36 +02:00
parent 1e6b21cfd4
commit eb6cba8f1a
11 changed files with 62 additions and 22 deletions

View file

@ -14,6 +14,8 @@ use Stancl\Tenancy\TenantDatabaseManagers\SQLiteDatabaseManager;
class TenantDatabaseManagerTest extends TestCase
{
public $autoInitTenancy = false;
/**
* @test
* @dataProvider database_manager_provider
@ -24,8 +26,6 @@ class TenantDatabaseManagerTest extends TestCase
$this->markTestSkipped('As to not bloat your computer with test databases, this test is not run by default.');
}
config()->set('database.default', $driver); // todo2 the DB creator would not work for MySQL when sqlite is used for the central DB
$name = 'db' . $this->randomString();
$this->assertFalse(app($databaseManager)->databaseExists($name));
app($databaseManager)->createDatabase($name);
@ -34,6 +34,20 @@ class TenantDatabaseManagerTest extends TestCase
$this->assertFalse(app($databaseManager)->databaseExists($name));
}
/** @test */
public function dbs_can_be_created_when_another_driver_is_used_for_the_central_db()
{
$this->assertSame('sqlite', config('database.default'));
$database = 'db' . $this->randomString();
app(MySQLDatabaseManager::class)->createDatabase($database);
$this->assertTrue(app(MySQLDatabaseManager::class)->databaseExists($database));
$database = 'db2' . $this->randomString();
app(PostgreSQLDatabaseManager::class)->createDatabase($database);
$this->assertTrue(app(PostgreSQLDatabaseManager::class)->databaseExists($database));
}
/**
* @test
* @dataProvider database_manager_provider