aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions_acp/build_cfg_template_test.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2011-02-01 14:09:52 +0100
committerJoas Schilling <nickvergessen@gmx.de>2011-02-01 14:09:52 +0100
commit6b00d7aa096b01ce6e59a8467f79eb193c25a35b (patch)
treecc3b4cdd973bc9aaf094145d318462704cd1fe6a /tests/functions_acp/build_cfg_template_test.php
parent2b70f3d0e2c85f4ff639aec1077afff3154506dc (diff)
downloadforums-6b00d7aa096b01ce6e59a8467f79eb193c25a35b.tar
forums-6b00d7aa096b01ce6e59a8467f79eb193c25a35b.tar.gz
forums-6b00d7aa096b01ce6e59a8467f79eb193c25a35b.tar.bz2
forums-6b00d7aa096b01ce6e59a8467f79eb193c25a35b.tar.xz
forums-6b00d7aa096b01ce6e59a8467f79eb193c25a35b.zip
[ticket/9823] Update Unit tests to the new system and correct some minor issues
PHPBB3-9823
Diffstat (limited to 'tests/functions_acp/build_cfg_template_test.php')
-rw-r--r--tests/functions_acp/build_cfg_template_test.php192
1 files changed, 192 insertions, 0 deletions
diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php
new file mode 100644
index 0000000000..c573c7cdb0
--- /dev/null
+++ b/tests/functions_acp/build_cfg_template_test.php
@@ -0,0 +1,192 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . 'user_mock.php';
+require_once dirname(__FILE__) . '../../phpBB/includes/functions_acp.php';
+
+class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
+{
+ public function build_cfg_template_text_data()
+ {
+ return array(
+ array(
+ array('text', 20, 255),
+ 'key_name',
+ array('config_key_name' => '1'),
+ 'config_key_name',
+ array(),
+ '<input id="key_name" type="text" size="20" maxlength="255" name="config[config_key_name]" value="1" />',
+ ),
+ array(
+ array('password', 20, 128),
+ 'key_name',
+ array('config_key_name' => '2'),
+ 'config_key_name',
+ array(),
+ '<input id="key_name" type="password" size="20" maxlength="128" name="config[config_key_name]" value="2" />',
+ ),
+ array(
+ array('text', 0, 255),
+ 'key_name',
+ array('config_key_name' => '3'),
+ 'config_key_name',
+ array(),
+ '<input id="key_name" type="text" maxlength="255" name="config[config_key_name]" value="3" />',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_text_data
+ */
+ public function test_build_cfg_template_text($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $user;
+
+ $user->lang = new phpbb_mock_lang();
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+
+ public function build_cfg_template_dimension_data()
+ {
+ return array(
+ array(
+ array('dimension', 20, 255),
+ 'key_name',
+ array('config_key_name_width' => 10, 'config_key_name_height' => 20),
+ 'config_key_name',
+ array(),
+ '<input id="key_name" type="text" size="20" maxlength="255" name="config[config_key_name_width]" value="10" /> x <input type="text" size="20" maxlength="255" name="config[config_key_name_height]" value="20" />',
+ ),
+ array(
+ array('dimension', 0, 255),
+ 'key_name',
+ array('config_key_name_width' => 10, 'config_key_name_height' => 20),
+ 'config_key_name',
+ array(),
+ '<input id="key_name" type="text" maxlength="255" name="config[config_key_name_width]" value="10" /> x <input type="text" maxlength="255" name="config[config_key_name_height]" value="20" />',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_dimension_data
+ */
+ public function test_build_cfg_template_dimension($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $user;
+
+ $user->lang = new phpbb_mock_lang();
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+
+ public function build_cfg_template_textarea_data()
+ {
+ return array(
+ array(
+ array('textarea', 5, 30),
+ 'key_name',
+ array('config_key_name' => 'phpBB'),
+ 'config_key_name',
+ array(),
+ '<textarea id="key_name" name="config[config_key_name]" rows="5" cols="30">phpBB</textarea>',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_textarea_data
+ */
+ public function test_build_cfg_template_textarea($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $user;
+
+ $user->lang = new phpbb_mock_lang();
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+
+ public function build_cfg_template_radio_data()
+ {
+ return array(
+ array(
+ array('radio', 'enabled_disabled'),
+ 'key_name',
+ array('config_key_name' => '0'),
+ 'config_key_name',
+ array(),
+ '<label><input type="radio" id="key_name" name="config[config_key_name]" value="1" class="radio" /> ENABLED</label><label><input type="radio" name="config[config_key_name]" value="0" checked="checked" class="radio" /> DISABLED</label>',
+ ),
+ array(
+ array('radio', 'enabled_disabled'),
+ 'key_name',
+ array('config_key_name' => '1'),
+ 'config_key_name',
+ array(),
+ '<label><input type="radio" id="key_name" name="config[config_key_name]" value="1" checked="checked" class="radio" /> ENABLED</label><label><input type="radio" name="config[config_key_name]" value="0" class="radio" /> DISABLED</label>',
+ ),
+ array(
+ array('radio', 'yes_no'),
+ 'key_name',
+ array('config_key_name' => '0'),
+ 'config_key_name',
+ array(),
+ '<label><input type="radio" id="key_name" name="config[config_key_name]" value="1" class="radio" /> YES</label><label><input type="radio" name="config[config_key_name]" value="0" checked="checked" class="radio" /> NO</label>',
+ ),
+ array(
+ array('radio', 'yes_no'),
+ 'key_name',
+ array('config_key_name' => '1'),
+ 'config_key_name',
+ array(),
+ '<label><input type="radio" id="key_name" name="config[config_key_name]" value="1" checked="checked" class="radio" /> YES</label><label><input type="radio" name="config[config_key_name]" value="0" class="radio" /> NO</label>',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_radio_data
+ */
+ public function test_build_cfg_template_radio($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $user;
+
+ $user->lang = new phpbb_mock_lang();
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+
+ public function build_cfg_template_append_data()
+ {
+ return array(
+ array(
+ array('textarea', 5, 30),
+ 'key_name',
+ array('config_key_name' => 'phpBB'),
+ 'config_key_name',
+ array('append' => 'Bertie is cool!'),
+ '<textarea id="key_name" name="config[config_key_name]" rows="5" cols="30">phpBB</textarea>Bertie is cool!',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_append_data
+ */
+ public function test_build_cfg_template_append($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $user;
+
+ $user->lang = new phpbb_mock_lang();
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+}