mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-03 13:05:44 +02:00
[ticket/11219] Add unit test for inserting into a sequence column
PHPBB3-11219
This commit is contained in:
parent
41a95d2c64
commit
a7404409a8
55
tests/dbal/write_sequence_test.php
Normal file
55
tests/dbal/write_sequence_test.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
$sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array(
|
||||||
|
'username' => $username,
|
||||||
|
'username_clean' => $username,
|
||||||
|
'user_permissions' => '',
|
||||||
|
'user_sig' => '',
|
||||||
|
'user_occ' => '',
|
||||||
|
'user_interests' => '',
|
||||||
|
));
|
||||||
|
$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'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user