1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 14:34:04 +00:00

Initial draft

This commit is contained in:
Samuel Štancl 2020-04-30 20:48:15 +02:00
parent 4ff82a950d
commit 5d7d208e2f
19 changed files with 376 additions and 186 deletions

View file

@ -32,12 +32,12 @@ class DatabaseManagerTest extends TestCase
}
/** @test */
public function the_default_db_is_used_when_based_on_is_null()
public function the_default_db_is_used_when_template_connection_is_null()
{
$this->assertSame('sqlite', config('database.default'));
config([
'database.connections.sqlite.foo' => 'bar',
'tenancy.database.based_on' => null,
'tenancy.database.template_connection' => null,
]);
tenancy()->init('test.localhost');

View file

@ -19,9 +19,8 @@ class DatabaseSchemaManagerTest extends TestCase
'database.default' => 'pgsql',
'database.connections.pgsql.database' => 'main',
'database.connections.pgsql.schema' => 'public',
'tenancy.database.based_on' => null,
'tenancy.database.template_connection' => null,
'tenancy.database.suffix' => '',
'tenancy.database.separate_by' => 'schema',
'tenancy.database_managers.pgsql' => \Stancl\Tenancy\TenantDatabaseManagers\PostgreSQLSchemaManager::class,
]);
}
@ -41,14 +40,14 @@ class DatabaseSchemaManagerTest extends TestCase
}
/** @test */
public function the_default_db_is_used_when_based_on_is_null()
public function the_default_db_is_used_when_template_connection_is_null()
{
config(['database.default' => 'pgsql']);
$this->assertSame('pgsql', config('database.default'));
config([
'database.connections.pgsql.foo' => 'bar',
'tenancy.database.based_on' => null,
'tenancy.database.template_connection' => null,
]);
tenancy()->init('test.localhost');
@ -63,7 +62,7 @@ class DatabaseSchemaManagerTest extends TestCase
$tenant = tenancy()->create(['schema.localhost']);
tenancy()->init('schema.localhost');
$this->assertSame($tenant->getDatabaseName(), config('database.connections.' . config('database.default') . '.schema'));
$this->assertSame($tenant->database()->getName(), config('database.connections.' . config('database.default') . '.schema'));
}
/** @test */

View file

@ -0,0 +1,24 @@
<?php
namespace Stancl\Tenancy\Tests;
class DatabaseUsersTest extends TestCase
{
/** @test */
public function users_are_created_when_permission_controlled_mysql_manager_is_used()
{
}
/** @test */
public function correct_grants_are_given_to_the_users()
{
}
/** @test */
public function having_existing_databases_without_users_and_switching_to_permission_controlled_mysql_manager_doesnt_break_existing_dbs()
{
}
}

View file

@ -180,7 +180,7 @@ class TenantManagerTest extends TestCase
'_tenancy_db_name' => $database,
]);
$this->assertSame($database, $tenant->getDatabaseName());
$this->assertSame($database, $tenant->database()->getName());
}
/** @test */

View file

@ -82,7 +82,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'database' => database_path('central.sqlite'),
],
'tenancy.database' => [
'based_on' => 'sqlite',
'template_connection' => 'sqlite',
'prefix' => 'tenant',
'suffix' => '.sqlite',
],