assertEquals($testDbName, uDb::getDbName($dsn)); } } public function testGetDbNameEmptyNames() { $testDbName = ""; $defaultDSNs = [ "mysql:host=db.example.com;port=3306;dbname=", "mysql:host=db.example.com;port=3306", "", null, "unsupported:host=localhost;port=5432;dbname=;user=test;password=mypass", "corrupt", "pgsql:", "sqlite", "sqlite3", "sqlite:" ]; foreach ($defaultDSNs as $dsn) { $this->assertEquals($testDbName, uDb::getDbName($dsn)); } } public function testGetDbFilename() { $testFileNames = [ "C:\\Program Files\\Database.db", ":memory:", "/tmp/testdb.db3" ]; foreach ($testFileNames as $fileName) { $this->assertEquals($fileName, uDb::getDbName("sqlite:$fileName")); } } } ?>