|
571 | 571 |
|
572 | 572 | expect(fn () => $manager->deleteDatabase($tenant)) |
573 | 573 | ->toThrow(InvalidArgumentException::class, 'Forbidden character'); |
574 | | - |
575 | | - if ($driver === 'mysql') { |
576 | | - // MySQLDatabaseManager reads charset/collation from config. |
577 | | - // An exception is thrown during validation if the parameter is not a string. |
578 | | - config(['database.connections.mysql.charset' => []]); |
579 | | - DB::purge('mysql'); |
580 | | - |
581 | | - $tenantWithNonStringCharset = Tenant::make([ |
582 | | - 'tenancy_db_name' => 'valid_db_name', |
583 | | - ]); |
584 | | - |
585 | | - expect(fn () => $manager->createDatabase($tenantWithNonStringCharset)) |
586 | | - ->toThrow(InvalidArgumentException::class, 'Parameter has to be a string.'); |
587 | | - |
588 | | - // Restore the default charset |
589 | | - config(['database.connections.mysql.charset' => 'utf8mb4']); |
590 | | - DB::purge('mysql'); |
591 | | - } |
592 | 574 | } else { |
593 | 575 | // Invalid username, createUser() and deleteUser() should |
594 | 576 | // throw an invalid argument exception. |
|
646 | 628 | } |
647 | 629 | })->with('database_managers'); |
648 | 630 |
|
| 631 | +test('mysql database manager validates charset and collation correctly', function () { |
| 632 | + $manager = app(MySQLDatabaseManager::class); |
| 633 | + $manager->setConnection('mysql'); |
| 634 | + |
| 635 | + config(['database.connections.mysql.charset' => []]); |
| 636 | + DB::purge('mysql'); |
| 637 | + |
| 638 | + $tenant = Tenant::make([ |
| 639 | + 'tenancy_db_name' => 'valid_db_name', |
| 640 | + ]); |
| 641 | + |
| 642 | + expect(fn () => $manager->createDatabase($tenant)) |
| 643 | + ->toThrow(InvalidArgumentException::class, 'Parameter has to be a string.'); |
| 644 | +}); |
| 645 | + |
649 | 646 | test('sqlite database manager validates database names correctly', function () { |
650 | 647 | $manager = app(SQLiteDatabaseManager::class); |
651 | 648 |
|
|
0 commit comments