mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-23 19:51:26 +02:00
[ticket/10942] Add unit tests for sql_concatenate
PHPBB3-10942
This commit is contained in:
64
tests/dbal/concatenate_test.php
Normal file
64
tests/dbal/concatenate_test.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class phpbb_dbal_concatenate_test extends phpbb_database_test_case
|
||||||
|
{
|
||||||
|
public function getDataSet()
|
||||||
|
{
|
||||||
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_concatenate_string()
|
||||||
|
{
|
||||||
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
|
$sql = 'SELECT config_name, ' . $db->sql_concatenate('config_name', "'" . $db->sql_escape('append') . "'") . ' AS string
|
||||||
|
FROM phpbb_config';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$db->sql_return_on_error(false);
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
array(
|
||||||
|
'config_name' => 'config1',
|
||||||
|
'string' => 'config1append',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'config_name' => 'config2',
|
||||||
|
'string' => 'config2append',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
$db->sql_fetchrowset($result)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_concatenate_statement()
|
||||||
|
{
|
||||||
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
|
$sql = 'SELECT config_name, ' . $db->sql_concatenate('config_name', 'config_value') . ' AS string
|
||||||
|
FROM phpbb_config';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$db->sql_return_on_error(false);
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
array(
|
||||||
|
'config_name' => 'config1',
|
||||||
|
'string' => 'config1foo',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'config_name' => 'config2',
|
||||||
|
'string' => 'config2bar',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
$db->sql_fetchrowset($result)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user