mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge remote-tracking branch 'naderman/ticket/10198' into develop
* naderman/ticket/10198: [ticket/10198] Test if schema allows reading & writing multibyte config values [ticket/10198] Verify behaviour of validate_config_vars with multibyte strings [ticket/10198] Verify behaviour of validate_range with multibyte strings
This commit is contained in:
commit
47348cc010
3 changed files with 74 additions and 36 deletions
38
tests/dbal/schema_test.php
Normal file
38
tests/dbal/schema_test.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2011 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||||
|
|
||||||
|
class phpbb_dbal_schema_test extends phpbb_database_test_case
|
||||||
|
{
|
||||||
|
public function getDataSet()
|
||||||
|
{
|
||||||
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_config_value_multibyte()
|
||||||
|
{
|
||||||
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
|
$value = str_repeat("\xC3\x84", 255);
|
||||||
|
$sql = "INSERT INTO phpbb_config
|
||||||
|
(config_name, config_value)
|
||||||
|
VALUES ('name', '$value')";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$sql = "SELECT config_value
|
||||||
|
FROM phpbb_config
|
||||||
|
WHERE config_name = 'name'";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$this->assertEquals($value, $row['config_value']);
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,19 +12,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
|
||||||
|
|
||||||
class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
|
class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Helper function which returns a string in a given length.
|
|
||||||
*/
|
|
||||||
static public function return_string($length)
|
|
||||||
{
|
|
||||||
$string = '';
|
|
||||||
for ($i = 0; $i < $length; $i++)
|
|
||||||
{
|
|
||||||
$string .= 'a';
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data sets that don't throw an error.
|
* Data sets that don't throw an error.
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +22,10 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
|
||||||
array(
|
array(
|
||||||
'test_bool' => array('lang' => 'TEST_BOOL', 'validate' => 'bool'),
|
'test_bool' => array('lang' => 'TEST_BOOL', 'validate' => 'bool'),
|
||||||
'test_string' => array('lang' => 'TEST_STRING', 'validate' => 'string'),
|
'test_string' => array('lang' => 'TEST_STRING', 'validate' => 'string'),
|
||||||
|
'test_string' => array('lang' => 'TEST_STRING', 'validate' => 'string'),
|
||||||
'test_string_128' => array('lang' => 'TEST_STRING_128', 'validate' => 'string:128'),
|
'test_string_128' => array('lang' => 'TEST_STRING_128', 'validate' => 'string:128'),
|
||||||
|
'test_string_128' => array('lang' => 'TEST_STRING_128', 'validate' => 'string:128'),
|
||||||
|
'test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64'),
|
||||||
'test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64'),
|
'test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64'),
|
||||||
'test_int' => array('lang' => 'TEST_INT', 'validate' => 'int'),
|
'test_int' => array('lang' => 'TEST_INT', 'validate' => 'int'),
|
||||||
'test_int_32' => array('lang' => 'TEST_INT', 'validate' => 'int:32'),
|
'test_int_32' => array('lang' => 'TEST_INT', 'validate' => 'int:32'),
|
||||||
|
@ -51,9 +41,12 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'test_bool' => true,
|
'test_bool' => true,
|
||||||
'test_string' => self::return_string(255),
|
'test_string' => str_repeat('a', 255),
|
||||||
'test_string_128' => self::return_string(128),
|
'test_string' => str_repeat("\xC3\x84", 255),
|
||||||
'test_string_32_64' => self::return_string(48),
|
'test_string_128' => str_repeat('a', 128),
|
||||||
|
'test_string_128' => str_repeat("\xC3\x84", 128),
|
||||||
|
'test_string_32_64' => str_repeat('a', 48),
|
||||||
|
'test_string_32_64' => str_repeat("\xC3\x84", 48),
|
||||||
'test_int' => 128,
|
'test_int' => 128,
|
||||||
'test_int_32' => 32,
|
'test_int_32' => 32,
|
||||||
'test_int_32_64' => 48,
|
'test_int_32_64' => 48,
|
||||||
|
@ -86,17 +79,32 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
|
array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
|
||||||
array('test_string_32_64' => self::return_string(20)),
|
array('test_string_32_64' => str_repeat('a', 20)),
|
||||||
|
array('SETTING_TOO_SHORT'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
|
||||||
|
array('test_string_32_64' => str_repeat("\xC3\x84", 20)),
|
||||||
array('SETTING_TOO_SHORT'),
|
array('SETTING_TOO_SHORT'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('test_string' => array('lang' => 'TEST_STRING', 'validate' => 'string')),
|
array('test_string' => array('lang' => 'TEST_STRING', 'validate' => 'string')),
|
||||||
array('test_string' => self::return_string(256)),
|
array('test_string' => str_repeat('a', 256)),
|
||||||
|
array('SETTING_TOO_LONG'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('test_string' => array('lang' => 'TEST_STRING', 'validate' => 'string')),
|
||||||
|
array('test_string' => str_repeat("\xC3\x84", 256)),
|
||||||
array('SETTING_TOO_LONG'),
|
array('SETTING_TOO_LONG'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
|
array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
|
||||||
array('test_string_32_64' => self::return_string(65)),
|
array('test_string_32_64' => str_repeat('a', 65)),
|
||||||
|
array('SETTING_TOO_LONG'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
|
||||||
|
array('test_string_32_64' => str_repeat("\xC3\x84", 65)),
|
||||||
array('SETTING_TOO_LONG'),
|
array('SETTING_TOO_LONG'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../mock/lang.php';
|
require_once dirname(__FILE__) . '/../mock/lang.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
|
||||||
|
|
||||||
class phpbb_functions_acp_validate_range_test extends phpbb_test_case
|
class phpbb_functions_acp_validate_range_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Helper function which returns a string in a given length.
|
|
||||||
*/
|
|
||||||
static public function return_string($length)
|
|
||||||
{
|
|
||||||
$string = '';
|
|
||||||
for ($i = 0; $i < $length; $i++)
|
|
||||||
{
|
|
||||||
$string .= 'a';
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data sets that don't throw an error.
|
* Data sets that don't throw an error.
|
||||||
*/
|
*/
|
||||||
|
@ -53,8 +41,10 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
|
||||||
array(array(array('column_type' => 'TINT:-32:64', 'lang' => 'TEST', 'value' => 16))),
|
array(array(array('column_type' => 'TINT:-32:64', 'lang' => 'TEST', 'value' => 16))),
|
||||||
|
|
||||||
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => ''))),
|
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => ''))),
|
||||||
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => self::return_string(255)))),
|
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => str_repeat('a', 255)))),
|
||||||
array(array(array('column_type' => 'VCHAR:128', 'lang' => 'TEST', 'value' => self::return_string(128)))),
|
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => str_repeat("\xC3\x84", 255)))),
|
||||||
|
array(array(array('column_type' => 'VCHAR:128', 'lang' => 'TEST', 'value' => str_repeat('a', 128)))),
|
||||||
|
array(array(array('column_type' => 'VCHAR:128', 'lang' => 'TEST', 'value' => str_repeat("\xC3\x84", 128)))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,8 +147,10 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
|
||||||
public function validate_range_data_too_long()
|
public function validate_range_data_too_long()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => self::return_string(256)))),
|
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => str_repeat('a', 256)))),
|
||||||
array(array(array('column_type' => 'VCHAR:128', 'lang' => 'TEST', 'value' => self::return_string(129)))),
|
array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => str_repeat("\xC3\x84", 256)))),
|
||||||
|
array(array(array('column_type' => 'VCHAR:128', 'lang' => 'TEST', 'value' => str_repeat('a', 129)))),
|
||||||
|
array(array(array('column_type' => 'VCHAR:128', 'lang' => 'TEST', 'value' => str_repeat("\xC3\x84", 129)))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue