Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
72.73% |
16 / 22 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_dbal_write_sequence_test | |
72.73% |
16 / 22 |
|
66.67% |
2 / 3 |
3.18 | |
0.00% |
0 / 1 |
| getDataSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| write_sequence_data | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_write_sequence | |
100.00% |
15 / 15 |
|
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_write_sequence_test extends phpbb_database_test_case |
| 15 | { |
| 16 | public function getDataSet() |
| 17 | { |
| 18 | return $this->createXMLDataSet(__DIR__ . '/fixtures/three_users.xml'); |
| 19 | } |
| 20 | |
| 21 | static public function write_sequence_data() |
| 22 | { |
| 23 | return array( |
| 24 | array( |
| 25 | 'ticket/11219', |
| 26 | 4, |
| 27 | ), |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @dataProvider write_sequence_data |
| 33 | */ |
| 34 | public function test_write_sequence($username, $expected) |
| 35 | { |
| 36 | $db = $this->new_dbal(); |
| 37 | |
| 38 | // dbal uses cache |
| 39 | global $cache; |
| 40 | $cache = new phpbb_mock_cache(); |
| 41 | |
| 42 | $sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array( |
| 43 | 'username' => $username, |
| 44 | 'username_clean' => $username, |
| 45 | 'user_permissions' => '', |
| 46 | 'user_sig' => '', |
| 47 | )); |
| 48 | $db->sql_query($sql); |
| 49 | |
| 50 | $this->assertEquals($expected, $db->sql_nextid()); |
| 51 | |
| 52 | $sql = "SELECT user_id |
| 53 | FROM phpbb_users |
| 54 | WHERE username_clean = '" . $db->sql_escape($username) . "'"; |
| 55 | $result = $db->sql_query_limit($sql, 1); |
| 56 | |
| 57 | $this->assertEquals($expected, $db->sql_fetchfield('user_id')); |
| 58 | } |
| 59 | } |