diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2010-03-27 10:21:16 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2010-03-27 10:42:09 +0100 |
commit | 53d316dc9ea34b1228591aa9cee766b2ec8abdc7 (patch) | |
tree | 89c281c742563c44f1742c29723063110ade406a /tests/dbal | |
parent | 147d6fd590b0ff0bbed153fd33dcead494f822d0 (diff) | |
download | forums-53d316dc9ea34b1228591aa9cee766b2ec8abdc7.tar forums-53d316dc9ea34b1228591aa9cee766b2ec8abdc7.tar.gz forums-53d316dc9ea34b1228591aa9cee766b2ec8abdc7.tar.bz2 forums-53d316dc9ea34b1228591aa9cee766b2ec8abdc7.tar.xz forums-53d316dc9ea34b1228591aa9cee766b2ec8abdc7.zip |
[feature/dbal-tests] Make some tests for build_array_data on SELECT
Diffstat (limited to 'tests/dbal')
-rw-r--r-- | tests/dbal/dbal.php | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/tests/dbal/dbal.php b/tests/dbal/dbal.php index 0239f91a2d..f90b5efeb5 100644 --- a/tests/dbal/dbal.php +++ b/tests/dbal/dbal.php @@ -246,12 +246,14 @@ class phpbb_dbal_test extends phpbb_database_test_case array('user_id', '', true, true, array(array('username_clean' => 'barfoo'), array('username_clean' => 'foobar'), array('username_clean' => 'bertie'))), - array('user_id', array(), false, false, false, true), array('user_id', array(), false, true, array()), - array('user_id', array(), true, false, false, true), array('user_id', array(), true, true, array(array('username_clean' => 'barfoo'), array('username_clean' => 'foobar'), array('username_clean' => 'bertie'))), + + // These here would throw errors and therefor $result should be false. + array('user_id', array(), false, false, false, true), + array('user_id', array(), true, false, false, true), ); } @@ -274,7 +276,48 @@ class phpbb_dbal_test extends phpbb_database_test_case if ($catch_error) { - $db->sql_return_on_error(falsee); + $db->sql_return_on_error(false); + } + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + + public static function build_array_data() + { + return array( + array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))), + array(array('username_clean' => 'barfoo', 'user_id' => 1), array(array('username_clean' => 'barfoo'))), + array(array('username_clean' => 'barfoo', 'user_id' => 2), array()), + + // These here would throw errors and therefor $result should be false. + array(array(), false, true), + array('no_array', false, true), + array(0, false, true), + ); + } + + /** + * @dataProvider build_array_data + */ + public function test_build_array($assoc_ary, $expected, $catch_error = false) + { + $db = $this->new_dbal(); + + if ($catch_error) + { + $db->sql_return_on_error(true); + } + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + WHERE ' . $db->sql_build_array('SELECT', $assoc_ary) . ' + ORDER BY user_id ASC'); + + if ($catch_error) + { + $db->sql_return_on_error(false); } $this->assertEquals($expected, $db->sql_fetchrowset($result)); |