From d59327a9c4dfcef41ccb884f396dadeff6aa1fbd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 16 Sep 2010 01:07:12 +0200 Subject: [PATCH] [ticket/9823] Unit tests for h_radio. PHPBB3-9823 --- tests/functions_acp/all_tests.php | 2 + tests/functions_acp/h_radio.php | 122 ++++++++++++++++++++++++++++++ tests/functions_acp/user_mock.php | 33 ++++++++ 3 files changed, 157 insertions(+) create mode 100644 tests/functions_acp/h_radio.php create mode 100644 tests/functions_acp/user_mock.php 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 @@ + 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + false, + false, + '', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + false, + false, + '', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + 'test_id', + false, + '', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + 'test_id', + false, + '', + ), + + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + false, + 'k', + '', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + false, + 'k', + '', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + false, + 'test_id', + 'k', + '', + ), + array( + 'test_name', + array( + 'test' => 'TEST', + 'second' => 'SEC_OPTION', + ), + 'test', + 'test_id', + 'k', + '', + ), + ); + } + + /** + * @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 @@ +