diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2010-09-16 01:07:12 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2011-02-01 13:38:41 +0100 |
commit | d59327a9c4dfcef41ccb884f396dadeff6aa1fbd (patch) | |
tree | 7ee736fc7aff4ea44e8ef9db1c3e4a8f58034cfa /tests/functions_acp | |
parent | eb2de91e7b3982c2613f93ab05ce4a2001c0f163 (diff) | |
download | forums-d59327a9c4dfcef41ccb884f396dadeff6aa1fbd.tar forums-d59327a9c4dfcef41ccb884f396dadeff6aa1fbd.tar.gz forums-d59327a9c4dfcef41ccb884f396dadeff6aa1fbd.tar.bz2 forums-d59327a9c4dfcef41ccb884f396dadeff6aa1fbd.tar.xz forums-d59327a9c4dfcef41ccb884f396dadeff6aa1fbd.zip |
[ticket/9823] Unit tests for h_radio.
PHPBB3-9823
Diffstat (limited to 'tests/functions_acp')
-rw-r--r-- | tests/functions_acp/all_tests.php | 2 | ||||
-rw-r--r-- | tests/functions_acp/h_radio.php | 122 | ||||
-rw-r--r-- | tests/functions_acp/user_mock.php | 33 |
3 files changed, 157 insertions, 0 deletions
diff --git a/tests/functions_acp/all_tests.php b/tests/functions_acp/all_tests.php index 6b2d676e60..d5f0c86dc9 100644 --- a/tests/functions_acp/all_tests.php +++ b/tests/functions_acp/all_tests.php @@ -16,6 +16,7 @@ require_once 'test_framework/framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; require_once 'functions_acp/build_select.php'; +require_once 'functions_acp/h_radio.php'; class phpbb_functions_acp_all_tests { @@ -29,6 +30,7 @@ class phpbb_functions_acp_all_tests $suite = new PHPUnit_Framework_TestSuite('phpBB Network Functions'); $suite->addTestSuite('phpbb_functions_acp_built_select_test'); + $suite->addTestSuite('phpbb_functions_acp_h_radio_test'); return $suite; } diff --git a/tests/functions_acp/h_radio.php b/tests/functions_acp/h_radio.php new file mode 100644 index 0000000000..6550c8f818 --- /dev/null +++ b/tests/functions_acp/h_radio.php @@ -0,0 +1,122 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once 'test_framework/framework.php'; +require_once 'functions_acp/user_mock.php'; +require_once '../phpBB/includes/functions_acp.php'; + +class phpbb_functions_acp_h_radio_test extends phpbb_test_case +{ + public function h_radio_data() + { + return array( + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + false, + false, + '<label><input type="radio" name="test_name" value="test" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + false, + false, + '<label><input type="radio" name="test_name" value="test" checked="checked" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + 'test_id', + false, + '<label><input type="radio" name="test_name" id="test_id" value="test" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + 'test_id', + false, + '<label><input type="radio" name="test_name" id="test_id" value="test" checked="checked" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>', + ), + + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + false, + 'k', + '<label><input type="radio" name="test_name" value="test" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + false, + 'k', + '<label><input type="radio" name="test_name" value="test" checked="checked" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + 'test_id', + 'k', + '<label><input type="radio" name="test_name" id="test_id" value="test" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + 'test_id', + 'k', + '<label><input type="radio" name="test_name" id="test_id" value="test" checked="checked" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>', + ), + ); + } + + /** + * @dataProvider h_radio_data + */ + 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/user_mock.php b/tests/functions_acp/user_mock.php new file mode 100644 index 0000000000..c7f62fc39b --- /dev/null +++ b/tests/functions_acp/user_mock.php @@ -0,0 +1,33 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* phpbb_mock_lang +* mock a user with some language-keys specified +*/ +class phpbb_mock_lang implements ArrayAccess +{ + public function offsetExists($offset) + { + return true; + } + + public function offsetGet($offset) + { + return $offset; + } + + public function offsetSet($offset, $value) + { + } + + public function offsetUnset($offset) + { + } +}
\ No newline at end of file |