mirror of
https://github.com/archtechx/tenancy.git
synced 2026-06-21 01:54:03 +00:00
Consider null parameters invalid
Parameters passed to validateParameter should always be non-null, and if they're null, an exception is thrown.
This commit is contained in:
parent
fbffeb84b3
commit
48b8aac42d
3 changed files with 11 additions and 13 deletions
|
|
@ -591,6 +591,7 @@ test('database managers validate parameters used in raw sql statements', functio
|
|||
$tenantWithInvalidDatabase = Tenant::make([
|
||||
'tenancy_db_name' => $invalidDatabaseName,
|
||||
'tenancy_db_username' => 'valid_USERNAME',
|
||||
'tenancy_db_password' => 'valid_password',
|
||||
]);
|
||||
|
||||
expect(fn () => $manager->createUser($tenantWithInvalidDatabase->database()))
|
||||
|
|
@ -615,16 +616,14 @@ test('database managers validate parameters used in raw sql statements', functio
|
|||
expect(fn () => $manager->createUser($tenantWithValidPassword->database()))
|
||||
->not()->toThrow(InvalidArgumentException::class, 'Forbidden character');
|
||||
|
||||
$tenantWithNullDbParameters = Tenant::make([
|
||||
'tenancy_db_name' => null,
|
||||
$tenantWithNullCredentials = Tenant::make([
|
||||
'tenancy_db_name' => 'valid_db_name',
|
||||
'tenancy_db_username' => null,
|
||||
'tenancy_db_password' => null,
|
||||
]);
|
||||
|
||||
// validateParameter() doesn't throw InvalidArgumentException if a parameter is null
|
||||
// (an exception will be thrown, but not by validateParameter()).
|
||||
expect(fn () => $manager->createUser($tenantWithNullDbParameters->database()))
|
||||
->not()->toThrow(InvalidArgumentException::class);
|
||||
expect(fn () => $manager->createUser($tenantWithNullCredentials->database()))
|
||||
->toThrow(InvalidArgumentException::class, 'Parameter cannot be null.');
|
||||
}
|
||||
})->with('database_managers');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue