pdo-document/tests/Unit/ModeTest.php

24 lines
707 B
PHP
Raw Normal View History

2024-10-05 19:43:41 +00:00
<?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);
});
});