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

Merge 3.x into master

This commit is contained in:
lukinovec 2023-02-17 15:48:00 +01:00
parent 617e9a7a73
commit 8fd19192ec
11 changed files with 105 additions and 54 deletions

View file

@ -79,7 +79,7 @@ test('ing events can be used to cancel db creation', function () {
});
$tenant = Tenant::create();
dispatch_now(new CreateDatabase($tenant));
dispatch_sync(new CreateDatabase($tenant));
pest()->assertFalse($tenant->database()->manager()->databaseExists(
$tenant->database()->getName()
@ -171,12 +171,13 @@ test('database is not migrated if creation is disabled', function () {
})->toListener()
);
Tenant::create([
$tenant = Tenant::create([
'tenancy_create_database' => false,
'tenancy_db_name' => 'already_created',
]);
expect(pest()->hasFailed())->toBeFalse();
// Assert test didn't fail
$this->assertTrue($tenant->exists());
});
class FooListener extends QueueableListener

View file

@ -302,7 +302,7 @@ test('database credentials can be provided to PermissionControlledMySQLDatabaseM
$mysql2DB->statement("CREATE USER `{$username}`@`%` IDENTIFIED BY '{$password}';");
$mysql2DB->statement("GRANT ALL PRIVILEGES ON *.* TO `{$username}`@`%` identified by '{$password}' WITH GRANT OPTION;");
$mysql2DB->statement("FLUSH PRIVILEGES;");
DB::purge('mysql2'); // forget the mysql2 connection so that it uses the new credentials the next time
config(['database.connections.mysql2.username' => $username]);
@ -347,7 +347,7 @@ test('tenant database can be created by using the username and password from ten
$mysqlDB->statement("CREATE USER `{$username}`@`%` IDENTIFIED BY '{$password}';");
$mysqlDB->statement("GRANT ALL PRIVILEGES ON *.* TO `{$username}`@`%` identified by '{$password}' WITH GRANT OPTION;");
$mysqlDB->statement("FLUSH PRIVILEGES;");
DB::purge('mysql2'); // forget the mysql2 connection so that it uses the new credentials the next time
// Remove `mysql` credentials to make sure we will be using the credentials from the tenant config