|
36 | 36 | use CodeIgniter\Router\RouteCollection; |
37 | 37 | use CodeIgniter\Router\Router; |
38 | 38 | use CodeIgniter\Security\Security; |
| 39 | +use CodeIgniter\Session\Handlers\DatabaseHandler; |
39 | 40 | use CodeIgniter\Session\Session; |
40 | 41 | use CodeIgniter\Test\CIUnitTestCase; |
41 | 42 | use CodeIgniter\Test\Mock\MockResponse; |
|
46 | 47 | use CodeIgniter\View\Cell; |
47 | 48 | use CodeIgniter\View\Parser; |
48 | 49 | use Config\App; |
| 50 | +use Config\Database as DatabaseConfig; |
49 | 51 | use Config\Exceptions; |
50 | 52 | use Config\Security as SecurityConfig; |
51 | 53 | use Config\Session as ConfigSession; |
@@ -275,6 +277,25 @@ public function testNewSessionWithInvalidHandler(string $driver): void |
275 | 277 | Services::session($config, false); |
276 | 278 | } |
277 | 279 |
|
| 280 | + #[PreserveGlobalState(false)] |
| 281 | + #[RunInSeparateProcess] |
| 282 | + public function testNewSessionWithInvalidDatabaseHandler(): void |
| 283 | + { |
| 284 | + $driver = config(DatabaseConfig::class)->tests['DBDriver']; |
| 285 | + |
| 286 | + if (in_array($driver, ['MySQLi', 'Postgre'], true)) { |
| 287 | + $this->markTestSkipped('This test case does not work with MySQLi and Postgre'); |
| 288 | + } |
| 289 | + |
| 290 | + $this->expectException(InvalidArgumentException::class); |
| 291 | + $this->expectExceptionMessage(sprintf('Invalid session database handler "%s" provided. Only "MySQLi" and "Postgre" are supported.', $driver)); |
| 292 | + |
| 293 | + $config = new ConfigSession(); |
| 294 | + |
| 295 | + $config->driver = DatabaseHandler::class; |
| 296 | + Services::session($config, false); |
| 297 | + } |
| 298 | + |
278 | 299 | /** |
279 | 300 | * @return iterable<string, array{0: string}> |
280 | 301 | */ |
|
0 commit comments