Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
25 / 25 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_dbal_cross_join_test | |
100.00% |
25 / 25 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| getDataSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| test_cross_join | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | class phpbb_dbal_cross_join_test extends phpbb_database_test_case |
| 15 | { |
| 16 | public function getDataSet() |
| 17 | { |
| 18 | return $this->createXMLDataSet(__DIR__.'/fixtures/massmail_crossjoin.xml'); |
| 19 | } |
| 20 | |
| 21 | public function test_cross_join() |
| 22 | { |
| 23 | $db = $this->new_dbal(); |
| 24 | |
| 25 | // http://tracker.phpbb.com/browse/PHPBB3-10296 |
| 26 | // Test CROSS JOIN with INNER JOIN |
| 27 | // Failed on Postgres, MSSQL and Oracle |
| 28 | $db->sql_return_on_error(true); |
| 29 | |
| 30 | $sql_ary = array( |
| 31 | 'SELECT' => 'u.username', |
| 32 | 'FROM' => array( |
| 33 | 'phpbb_users' => 'u', |
| 34 | 'phpbb_user_group' => 'ug', |
| 35 | ), |
| 36 | 'LEFT_JOIN' => array( |
| 37 | array( |
| 38 | 'FROM' => array( |
| 39 | 'phpbb_bans' => 'b', |
| 40 | ), |
| 41 | 'ON' => 'b.ban_item = ' . $db->cast_expr_to_string('u.user_id'), |
| 42 | ), |
| 43 | ), |
| 44 | 'WHERE' => 'ug.group_id = 1 |
| 45 | AND u.user_id = ug.user_id |
| 46 | AND b.ban_id IS NULL', |
| 47 | 'ORDER_BY' => 'u.username', |
| 48 | ); |
| 49 | $sql = $db->sql_build_query('SELECT', $sql_ary); |
| 50 | $result = $db->sql_query($sql); |
| 51 | |
| 52 | $db->sql_return_on_error(false); |
| 53 | |
| 54 | $this->assertEquals(array(array('username' => 'mass email')), $db->sql_fetchrowset($result)); |
| 55 | } |
| 56 | } |