mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 18:04:03 +00:00
Fix non-string parameter validation assertion
This commit is contained in:
parent
e59195eefe
commit
66ae88a325
1 changed files with 14 additions and 14 deletions
|
|
@ -568,6 +568,20 @@ test('database managers validate parameters that cannot be bound', function ($dr
|
|||
|
||||
expect(fn () => $manager->deleteDatabase($tenant))
|
||||
->toThrow(InvalidArgumentException::class, 'Forbidden character');
|
||||
|
||||
if ($driver === 'mysql') {
|
||||
// MySQLDatabaseManager reads charset/collation from config.
|
||||
// An exception is thrown during validation if the parameter is not a string.
|
||||
config(['database.connections.mysql.charset' => []]);
|
||||
DB::purge('mysql');
|
||||
|
||||
$tenantWithNonStringCharset = Tenant::make([
|
||||
'tenancy_db_name' => 'valid_db_name',
|
||||
]);
|
||||
|
||||
expect(fn () => $manager->createDatabase($tenantWithNonStringCharset))
|
||||
->toThrow(InvalidArgumentException::class, 'Parameter has to be a string.');
|
||||
}
|
||||
} else {
|
||||
// Invalid username, createUser() and deleteUser() should
|
||||
// throw an invalid argument exception.
|
||||
|
|
@ -612,20 +626,6 @@ test('database managers validate parameters that cannot be bound', function ($dr
|
|||
// (an exception will be thrown, but not by validateParameter()).
|
||||
expect(fn () => $manager->createUser($tenantWithNullDbParameters->database()))
|
||||
->not()->toThrow(InvalidArgumentException::class);
|
||||
|
||||
if ($driver === 'mysql') {
|
||||
// MySQLDatabaseManager gets the charset from the config
|
||||
// Validation throws if the parameter is not a string
|
||||
$tenantWithNonStringCharset = Tenant::make([
|
||||
'tenancy_db_name' => 'valid_database_name890',
|
||||
'tenancy_db_username' => 'valid-username',
|
||||
]);
|
||||
|
||||
config(['database.connections.mysql.charset' => []]);
|
||||
|
||||
expect(fn () => $manager->createDatabase($tenantWithNonStringCharset))
|
||||
->toThrow(InvalidArgumentException::class, 'Parameter has to be a string.');
|
||||
}
|
||||
}
|
||||
})->with('database_managers');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue