aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dbal')
-rw-r--r--tests/dbal/all_tests.php40
-rw-r--r--tests/dbal/dbal.php43
-rw-r--r--tests/dbal/fixtures/two_users.xml15
3 files changed, 98 insertions, 0 deletions
diff --git a/tests/dbal/all_tests.php b/tests/dbal/all_tests.php
new file mode 100644
index 0000000000..7aee0f6b16
--- /dev/null
+++ b/tests/dbal/all_tests.php
@@ -0,0 +1,40 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_dbal_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'dbal/dbal.php';
+
+class phpbb_dbal_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Database Abstraction Layer');
+
+ $suite->addTestSuite('phpbb_dbal_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_dbal_all_tests::main')
+{
+ phpbb_dbal_all_tests::main();
+}
diff --git a/tests/dbal/dbal.php b/tests/dbal/dbal.php
new file mode 100644
index 0000000000..a77279105f
--- /dev/null
+++ b/tests/dbal/dbal.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/functions.php';
+
+class phpbb_dbal_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/two_users.xml');
+ }
+
+ public function test_select_row()
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ WHERE user_id = 2');
+ $row = $db->sql_fetchrow($result);
+
+ $this->assertEquals(array('username_clean' => 'foobar'), $row);
+ }
+
+ public function test_select_field()
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ WHERE user_id = 2');
+
+ $this->assertEquals('foobar', $db->sql_fetchfield('username_clean'));
+ }
+}
+
diff --git a/tests/dbal/fixtures/two_users.xml b/tests/dbal/fixtures/two_users.xml
new file mode 100644
index 0000000000..255f061bd4
--- /dev/null
+++ b/tests/dbal/fixtures/two_users.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username_clean</column>
+ <row>
+ <value>1</value>
+ <value>barfoo</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>foobar</value>
+ </row>
+ </table>
+</dataset>