aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions_acp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functions_acp')
-rw-r--r--tests/functions_acp/build_cfg_template_test.php50
-rw-r--r--tests/functions_acp/build_select_test.php14
-rw-r--r--tests/functions_acp/h_radio_test.php14
-rw-r--r--tests/functions_acp/validate_config_vars_test.php19
-rw-r--r--tests/functions_acp/validate_range_test.php26
5 files changed, 91 insertions, 32 deletions
diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php
index acf4da1bd6..7f8db799c5 100644
--- a/tests/functions_acp/build_cfg_template_test.php
+++ b/tests/functions_acp/build_cfg_template_test.php
@@ -234,4 +234,54 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
}
+
+ public function build_cfg_template_select_data()
+ {
+ return array(
+ array(
+ array('select'),
+ 'key_name',
+ array('config_key_name' => '0'),
+ 'config_key_name',
+ array('method' => 'select_helper'),
+ '<select id="key_name" name="config[config_key_name]"><option value="1">First_Option</option><option value="2" selected="selected">Second_Option</option><option value="3">Third_Option</option></select>',
+ ),
+ array(
+ array('select', 8),
+ 'key_name',
+ array('config_key_name' => '1'),
+ 'config_key_name',
+ array('method' => 'select_helper'),
+ '<select id="key_name" name="config[config_key_name]" size="8"><option value="1">First_Option</option><option value="2" selected="selected">Second_Option</option><option value="3">Third_Option</option></select>',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_select_data
+ */
+ public function test_build_cfg_template_select($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $module, $user, $phpbb_dispatcher;
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ $user->module = $this;
+ $module = $user;
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+
+ public function select_helper()
+ {
+ return build_select(
+ array(
+ '1' => 'First_Option',
+ '2' => 'Second_Option',
+ '3' => 'Third_Option',
+ ),
+ '2'
+ );
+ }
}
diff --git a/tests/functions_acp/build_select_test.php b/tests/functions_acp/build_select_test.php
index aca49b7655..c44fd97ec3 100644
--- a/tests/functions_acp/build_select_test.php
+++ b/tests/functions_acp/build_select_test.php
@@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_built_select_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
public function build_select_data()
{
return array(
@@ -46,10 +56,6 @@ class phpbb_functions_acp_built_select_test extends phpbb_test_case
*/
public function test_build_select($option_ary, $option_default, $expected)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$this->assertEquals($expected, build_select($option_ary, $option_default));
}
}
diff --git a/tests/functions_acp/h_radio_test.php b/tests/functions_acp/h_radio_test.php
index a61f2e8975..4c1872d341 100644
--- a/tests/functions_acp/h_radio_test.php
+++ b/tests/functions_acp/h_radio_test.php
@@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_h_radio_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
public function h_radio_data()
{
return array(
@@ -111,10 +121,6 @@ class phpbb_functions_acp_h_radio_test extends phpbb_test_case
*/
public function test_h_radio($name, $input_ary, $input_default, $id, $key, $expected)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$this->assertEquals($expected, h_radio($name, $input_ary, $input_default, $id, $key));
}
}
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index 7cd7fa3892..acc98fbf0d 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -8,9 +8,20 @@
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
/**
* Data sets that don't throw an error.
*/
@@ -60,10 +71,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
*/
public function test_validate_config_vars_fit($test_data, $cfg_array)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_config_vars($test_data, $cfg_array, $phpbb_error);
@@ -146,10 +153,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
*/
public function test_validate_config_vars_error($test_data, $cfg_array, $expected)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_config_vars($test_data, $cfg_array, $phpbb_error);
diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php
index 8606158251..cb028d4d07 100644
--- a/tests/functions_acp/validate_range_test.php
+++ b/tests/functions_acp/validate_range_test.php
@@ -12,6 +12,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_validate_range_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
/**
* Data sets that don't throw an error.
*/
@@ -52,10 +62,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_fit($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
@@ -91,10 +97,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_too_low($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
@@ -130,10 +132,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_too_big($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
@@ -158,10 +156,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_too_long($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);