aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dbal/schema_test.php38
-rw-r--r--tests/functions_acp/validate_config_vars_test.php46
-rw-r--r--tests/functions_acp/validate_range_test.php26
3 files changed, 74 insertions, 36 deletions
diff --git a/tests/dbal/schema_test.php b/tests/dbal/schema_test.php
new file mode 100644
index 0000000000..2475a85708
--- /dev/null
+++ b/tests/dbal/schema_test.php
@@ -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']);
+ }
+}
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index aa63bc38df..761788e264 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -13,19 +13,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
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.
*/
public function validate_config_vars_fit_data()
@@ -35,8 +22,11 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
array(
'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_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_int' => array('lang' => 'TEST_INT', 'validate' => 'int'),
'test_int_32' => array('lang' => 'TEST_INT', 'validate' => 'int:32'),
'test_int_32_64' => array('lang' => 'TEST_INT', 'validate' => 'int:32:64'),
@@ -51,9 +41,12 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
),
array(
'test_bool' => true,
- 'test_string' => self::return_string(255),
- 'test_string_128' => self::return_string(128),
- 'test_string_32_64' => self::return_string(48),
+ 'test_string' => str_repeat('a', 255),
+ 'test_string' => str_repeat("\xC3\x84", 255),
+ '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_32' => 32,
'test_int_32_64' => 48,
@@ -86,17 +79,32 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
return array(
array(
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(
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(
+ array('test_string_32_64' => array('lang' => 'TEST_STRING_32_64', 'validate' => 'string:32:64')),
+ 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' => self::return_string(65)),
+ array('test_string_32_64' => str_repeat("\xC3\x84", 65)),
array('SETTING_TOO_LONG'),
),
diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php
index a9c9612ad7..11b7f87957 100644
--- a/tests/functions_acp/validate_range_test.php
+++ b/tests/functions_acp/validate_range_test.php
@@ -8,24 +8,12 @@
*/
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';
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.
*/
public function validate_range_data_fit()
@@ -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' => 'VCHAR', 'lang' => 'TEST', 'value' => ''))),
- array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => self::return_string(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('a', 255)))),
+ 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()
{
return array(
- array(array(array('column_type' => 'VCHAR', 'lang' => 'TEST', 'value' => self::return_string(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('a', 256)))),
+ 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)))),
);
}