mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/dbal-tests] Tests for $db->sql_query_limit()
This commit is contained in:
parent
a7581085e0
commit
c6442ce640
2 changed files with 47 additions and 1 deletions
|
@ -14,7 +14,7 @@ class phpbb_dbal_test extends phpbb_database_test_case
|
||||||
{
|
{
|
||||||
public function getDataSet()
|
public function getDataSet()
|
||||||
{
|
{
|
||||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/two_users.xml');
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/three_users.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_select_row()
|
public function test_select_row()
|
||||||
|
@ -39,5 +39,47 @@ class phpbb_dbal_test extends phpbb_database_test_case
|
||||||
|
|
||||||
$this->assertEquals('foobar', $db->sql_fetchfield('username_clean'));
|
$this->assertEquals('foobar', $db->sql_fetchfield('username_clean'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function query_limit_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(0, 0, array(array('username_clean' => 'barfoo'),
|
||||||
|
array('username_clean' => 'foobar'),
|
||||||
|
array('username_clean' => 'bertie'))),
|
||||||
|
array(0, 1, array(array('username_clean' => 'foobar'),
|
||||||
|
array('username_clean' => 'bertie'))),
|
||||||
|
array(1, 0, array(array('username_clean' => 'barfoo'))),
|
||||||
|
array(1, 1, array(array('username_clean' => 'foobar'))),
|
||||||
|
array(1, 2, array(array('username_clean' => 'bertie'))),
|
||||||
|
array(2, 0, array(array('username_clean' => 'barfoo'),
|
||||||
|
array('username_clean' => 'foobar'))),
|
||||||
|
array(2, 2, array(array('username_clean' => 'bertie'))),
|
||||||
|
array(2, 5, array()),
|
||||||
|
array(10, 1, array(array('username_clean' => 'foobar'),
|
||||||
|
array('username_clean' => 'bertie'))),
|
||||||
|
array(10, 5, array()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider query_limit_data
|
||||||
|
*/
|
||||||
|
public function test_query_limit($total, $offset, $expected)
|
||||||
|
{
|
||||||
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
|
$result = $db->sql_query_limit('SELECT username_clean
|
||||||
|
FROM phpbb_users
|
||||||
|
ORDER BY user_id', $total, $offset);
|
||||||
|
|
||||||
|
$ary = array();
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$ary[] = $row;
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $ary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,9 @@
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>foobar</value>
|
<value>foobar</value>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>3</value>
|
||||||
|
<value>bertie</value>
|
||||||
|
</row>
|
||||||
</table>
|
</table>
|
||||||
</dataset>
|
</dataset>
|
Loading…
Add table
Reference in a new issue