aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/write_sequence_test.php
blob: a2d5921797254b2b5a57cf59c27f3a1cb88d3237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

class phpbb_dbal_write_sequence_test extends phpbb_database_test_case
{
	public function getDataSet()
	{
		return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/three_users.xml');
	}

	static public function write_sequence_data()
	{
		return array(
			array(
				'ticket/11219',
				4,
			),
		);
	}

	/**
	* @dataProvider write_sequence_data
	*/
	public function test_write_sequence($username, $expected)
	{
		$db = $this->new_dbal();

		// dbal uses cache
		global $cache;
		$cache = new phpbb_mock_cache();

		$sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array(
			'username'			=> $username,
			'username_clean'	=> $username,
			'user_permissions'	=> '',
			'user_sig'			=> '',
		));
		$db->sql_query($sql);

		$this->assertEquals($expected, $db->sql_nextid());

		$sql = "SELECT user_id
			FROM phpbb_users
			WHERE username_clean = '" . $db->sql_escape($username) . "'";
		$result = $db->sql_query_limit($sql, 1);

		$this->assertEquals($expected, $db->sql_fetchfield('user_id'));
	}
}