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

Merge branch 'db-users-rewrite' of github.com:stancl/tenancy into db-users-rewrite

This commit is contained in:
Samuel Štancl 2020-04-30 20:48:50 +02:00
commit ea72a7b4c7
5 changed files with 16 additions and 10 deletions

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Stancl\Tenancy\Contracts; namespace Stancl\Tenancy\Contracts;
use Stancl\Tenancy\DatabaseConfig; use Stancl\Tenancy\DatabaseConfig;
@ -7,5 +9,6 @@ use Stancl\Tenancy\DatabaseConfig;
interface ManagesDatabaseUsers interface ManagesDatabaseUsers
{ {
public function createUser(DatabaseConfig $databaseConfig): void; public function createUser(DatabaseConfig $databaseConfig): void;
public function deleteUser(DatabaseConfig $databaseConfig): void; public function deleteUser(DatabaseConfig $databaseConfig): void;
} }

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Stancl\Tenancy; namespace Stancl\Tenancy;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@ -104,7 +106,7 @@ class DatabaseConfig
// and it doesn't exist, we'll go for the default DB template. // and it doesn't exist, we'll go for the default DB template.
if (! array_key_exists($name, config('database.connections'))) { if (! array_key_exists($name, config('database.connections'))) {
$name = config('tenancy.database.template_connection') ?? DatabaseManager::$originalDefaultConnectionName; $name = config('tenancy.database.template_connection') ?? DatabaseManager::$originalDefaultConnectionName;
}; }
return $name; return $name;
} }

View file

@ -160,7 +160,7 @@ class DatabaseManager
} }
foreach ($afterCreating as $item) { foreach ($afterCreating as $item) {
if (is_object($item) && !$item instanceof Closure) { if (is_object($item) && ! $item instanceof Closure) {
$item->handle($tenant); $item->handle($tenant);
} else { } else {
$item($tenant); $item($tenant);

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Stancl\Tenancy\TenantDatabaseManagers; namespace Stancl\Tenancy\TenantDatabaseManagers;
use Stancl\Tenancy\Contracts\ManagesDatabaseUsers; use Stancl\Tenancy\Contracts\ManagesDatabaseUsers;

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Stancl\Tenancy\Tests; namespace Stancl\Tenancy\Tests;
class DatabaseUsersTest extends TestCase class DatabaseUsersTest extends TestCase
@ -7,18 +9,15 @@ class DatabaseUsersTest extends TestCase
/** @test */ /** @test */
public function users_are_created_when_permission_controlled_mysql_manager_is_used() public function users_are_created_when_permission_controlled_mysql_manager_is_used()
{ {
} }
/** @test */ /** @test */
public function correct_grants_are_given_to_the_users() public function correct_grants_are_given_to_the_users()
{ {
} }
/** @test */ /** @test */
public function having_existing_databases_without_users_and_switching_to_permission_controlled_mysql_manager_doesnt_break_existing_dbs() public function having_existing_databases_without_users_and_switching_to_permission_controlled_mysql_manager_doesnt_break_existing_dbs()
{ {
} }
} }