aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/cross_join_test.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2011-11-15 22:14:28 +0100
committerJoas Schilling <nickvergessen@gmx.de>2011-11-15 22:14:28 +0100
commite8686d9dad6522b30c2aeafb0e6e8dbe91cfb8db (patch)
tree3c7ffa29c8d108d1b90ca7578a9e000f5ac327ee /tests/dbal/cross_join_test.php
parent00f792f16f6f8c9a826c5a44e539fb3aeb80c340 (diff)
downloadforums-e8686d9dad6522b30c2aeafb0e6e8dbe91cfb8db.tar
forums-e8686d9dad6522b30c2aeafb0e6e8dbe91cfb8db.tar.gz
forums-e8686d9dad6522b30c2aeafb0e6e8dbe91cfb8db.tar.bz2
forums-e8686d9dad6522b30c2aeafb0e6e8dbe91cfb8db.tar.xz
forums-e8686d9dad6522b30c2aeafb0e6e8dbe91cfb8db.zip
[ticket/10296] Add unit test for CROSS JOIN with INNER JOIN
PHPBB3-10296
Diffstat (limited to 'tests/dbal/cross_join_test.php')
-rw-r--r--tests/dbal/cross_join_test.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/dbal/cross_join_test.php b/tests/dbal/cross_join_test.php
new file mode 100644
index 0000000000..7110c7a2ea
--- /dev/null
+++ b/tests/dbal/cross_join_test.php
@@ -0,0 +1,55 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
+
+class phpbb_dbal_cross_join_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/massmail_crossjoin.xml');
+ }
+
+ public function test_cross_join()
+ {
+ $db = $this->new_dbal();
+
+ // http://tracker.phpbb.com/browse/PHPBB3-10296
+ // Test CROSS JOIN with INNER JOIN
+ // Failed on Postgres, MSSQL and Oracle
+ $db->sql_return_on_error(true);
+
+ $sql_ary = array(
+ 'SELECT' => 'u.username',
+ 'FROM' => array(
+ 'phpbb_users' => 'u',
+ 'phpbb_user_group' => 'ug',
+ ),
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(
+ 'phpbb_banlist' => 'b',
+ ),
+ 'ON' => 'u.user_id = b.ban_userid',
+ ),
+ ),
+ 'WHERE' => 'ug.group_id = 1
+ AND u.user_id = ug.user_id
+ AND b.ban_id IS NULL',
+ 'ORDER_BY' => 'u.username',
+ );
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(array('username' => 'mass email')), $db->sql_fetchrowset($result));
+ }
+}