Derive mode from DSN function
- Add headers in all files - Minor field name changes
This commit is contained in:
39
tests/unit/ModeTest.php
Normal file
39
tests/unit/ModeTest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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('Derive from DSN succeeds for PostgreSQL')]
|
||||
public function testDeriveFromDSNSucceedsForPostgreSQL(): void
|
||||
{
|
||||
$this->assertEquals(Mode::PgSQL, Mode::deriveFromDSN('pgsql:Host=localhost'), 'PostgreSQL mode incorrect');
|
||||
}
|
||||
|
||||
#[TestDox('Derive from DSN succeeds for SQLite')]
|
||||
public function testDeriveFromDSNSucceedsForSQLite(): void
|
||||
{
|
||||
$this->assertEquals(Mode::SQLite, Mode::deriveFromDSN('sqlite:data.db'), 'SQLite mode incorrect');
|
||||
}
|
||||
|
||||
#[TestDox('Derive from DSN fails for MySQL')]
|
||||
public function testDeriveFromDSNFailsForMySQL(): void
|
||||
{
|
||||
$this->expectException(DocumentException::class);
|
||||
Mode::deriveFromDSN('mysql:Host=localhost');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user