Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
27 / 27 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | use Tests\Phexium\Integration\Support\PdoRegistry; |
| 11 | |
| 12 | test('initializes Sqlite database with test schema', function (): void { |
| 13 | PdoRegistry::initializeSqlite(false); |
| 14 | $pdo = PdoRegistry::getConnection(); |
| 15 | expect($pdo)->toBeInstanceOf(PDO::class); |
| 16 | |
| 17 | $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='sample'"; |
| 18 | $result = $pdo->query($sql); |
| 19 | expect($result->fetchColumn())->toBe('sample'); |
| 20 | |
| 21 | PdoRegistry::cleanupSqlite(); |
| 22 | }); |
| 23 | |
| 24 | test('initializes Mysql database with test schema', function (): void { |
| 25 | $dbName = PdoRegistry::initializeMysql(false); |
| 26 | $pdo = PdoRegistry::getConnection(); |
| 27 | expect($pdo)->toBeInstanceOf(PDO::class); |
| 28 | |
| 29 | $sql = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='sample'"; |
| 30 | $result = $pdo->query($sql); |
| 31 | expect($result->fetchColumn())->toBe('sample'); |
| 32 | |
| 33 | PdoRegistry::cleanupMysql($dbName); |
| 34 | }); |
| 35 | |
| 36 | test('initializes Postgresql database with test schema', function (): void { |
| 37 | $dbName = PdoRegistry::initializePostgresql(false); |
| 38 | $pdo = PdoRegistry::getConnection(); |
| 39 | expect($pdo)->toBeInstanceOf(PDO::class); |
| 40 | |
| 41 | $sql = "SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename='sample'"; |
| 42 | $result = $pdo->query($sql); |
| 43 | expect($result->fetchColumn())->toBe('sample'); |
| 44 | |
| 45 | PdoRegistry::cleanupPostgresql($dbName); |
| 46 | }); |