From 94bc65e2038407b8b6d2b23c195b232e07208d22 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 26 Mar 2010 16:39:37 +0100 Subject: [feature/dbal-tests] Added database test & refactored test framework There is now a phpbb_database_test_case which can be used as a base class for tests that require database access. You have to set up a test_config.php file in your tests/ directory containing host, user, pass etc. Extra test functionality has been moved to phpbb_test_case_helpers to provide the same functionality in database tests and regular tests without duplicating the code. This is achieved through delegation of method calls. --- tests/test_framework/phpbb_database_test_case.php | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/test_framework/phpbb_database_test_case.php (limited to 'tests/test_framework/phpbb_database_test_case.php') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php new file mode 100644 index 0000000000..f0aa54ec8d --- /dev/null +++ b/tests/test_framework/phpbb_database_test_case.php @@ -0,0 +1,42 @@ +test_case_helpers) + { + $this->test_case_helpers = new phpbb_test_case_helpers($this); + } + } + + public function getConnection() + { + $this->init_test_case_helpers(); + $database_config = $this->test_case_helpers->get_database_config(); + + $pdo = new PDO('mysql:host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']); + return $this->createDefaultDBConnection($pdo, 'testdb'); + } + + public function new_dbal() + { + $this->init_test_case_helpers(); + return $this->test_case_helpers->new_dbal(); + } + + public function setExpectedTriggerError($errno, $message = '') + { + $this->init_test_case_helpers(); + $this->test_case_helpers->setExpectedTriggerError($errno, $message); + } +} -- cgit v1.2.1