40 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * @author Daniel J. Summers <daniel@bitbadger.solutions>
 | |
|  * @license MIT
 | |
|  */
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| namespace Test\Unit;
 | |
| 
 | |
| use BitBadger\PDODocument\{DocumentException, Mode};
 | |
| use PHPUnit\Framework\Attributes\TestDox;
 | |
| use PHPUnit\Framework\TestCase;
 | |
| 
 | |
| /**
 | |
|  * Unit tests for the Mode enumeration
 | |
|  */
 | |
| #[TestDox('Mode (Unit tests)')]
 | |
| class ModeTest extends TestCase
 | |
| {
 | |
|     #[TestDox('deriveFromDSN() succeeds for PostgreSQL')]
 | |
|     public function testDeriveFromDSNSucceedsForPostgreSQL(): void
 | |
|     {
 | |
|         $this->assertEquals(Mode::PgSQL, Mode::deriveFromDSN('pgsql:Host=localhost'), 'PostgreSQL mode incorrect');
 | |
|     }
 | |
| 
 | |
|     #[TestDox('deriveFromDSN() succeeds for SQLite')]
 | |
|     public function testDeriveFromDSNSucceedsForSQLite(): void
 | |
|     {
 | |
|         $this->assertEquals(Mode::SQLite, Mode::deriveFromDSN('sqlite:data.db'), 'SQLite mode incorrect');
 | |
|     }
 | |
| 
 | |
|     #[TestDox('deriveFromDSN() fails for MySQL')]
 | |
|     public function testDeriveFromDSNFailsForMySQL(): void
 | |
|     {
 | |
|         $this->expectException(DocumentException::class);
 | |
|         Mode::deriveFromDSN('mysql:Host=localhost');
 | |
|     }
 | |
| }
 |