24 lines
		
	
	
		
			707 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			707 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * @author Daniel J. Summers <daniel@bitbadger.solutions>
 | |
|  * @license MIT
 | |
|  */
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| use BitBadger\PDODocument\{DocumentException, Mode};
 | |
| 
 | |
| pest()->group('unit');
 | |
| 
 | |
| describe('::deriveFromDSN()', function () {
 | |
|     test('derives for PostgreSQL', function () {
 | |
|         expect(Mode::deriveFromDSN('pgsql:Host=localhost'))->toBe(Mode::PgSQL);
 | |
|     })->group('postgresql');
 | |
|     test('derives for SQLite', function () {
 | |
|         expect(Mode::deriveFromDSN('sqlite:data.db'))->toBe(Mode::SQLite);
 | |
|     })->group('sqlite');
 | |
|     test('throws for other drivers', function () {
 | |
|         expect(fn() => Mode::deriveFromDSN('mysql:Host=localhost'))->toThrow(DocumentException::class);
 | |
|     });
 | |
| });
 |