From 17b17bc9399c0e72bebb74979f42aae5a683ae8b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 14 Feb 2011 09:15:51 +0100 Subject: [PATCH] [task/refactor-db-testcase] Improve error message of db tests If database tests cannot be run the error message is ambigous. This commit makes it clearer: - whether the supplied dbms is supported by us - which dbms are supported by us - whether the required PDO extension is loaded PHPBB3-10043 --- .../phpbb_database_test_connection_manager.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index e4b306f13f..3389081c4e 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -76,7 +76,14 @@ class phpbb_database_test_connection_manager break; } - $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']);; + try + { + $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']); + } + catch (PDOException $e) + { + throw new Exception("Unable do connect to $dsn with error: {$e->getMessage()}"); + } // good for debug // $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -330,7 +337,9 @@ class phpbb_database_test_connection_manager } else { - trigger_error('Database unsupported', E_USER_ERROR); + $message = 'Supplied dbms is unsupported, must be one of: '; + $message .= implode(', ', array_keys($available_dbms)); + throw new Exception($message); } } }