From 15929201b8cadc64f4a0fbcb49ddf5b6426f79a6 Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Tue, 24 Jun 2014 22:27:30 +0530 Subject: [ticket/12334] Add get_profile_value_raw unit tests for type_dropdown PHPBB3-12334 --- tests/profilefields/type_dropdown_test.php | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests/profilefields') diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php index 0e92afd504..ae5402177a 100644 --- a/tests/profilefields/type_dropdown_test.php +++ b/tests/profilefields/type_dropdown_test.php @@ -170,6 +170,54 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case $this->assertSame($expected, $result, $description); } + public function get_profile_value_raw_data() + { + return array( + array( + '4', + array('field_show_novalue' => true), + '4', + 'Field should return the correct raw value', + ), + array( + '', + array('field_show_novalue' => false), + null, + 'Field should return correct raw value', + ), + array( + '', + array('field_show_novalue' => true), + 0, + 'Field should return correct raw value', + ), + array( + null, + array('field_show_novalue' => false), + null, + 'Field should return correct raw value', + ), + array( + null, + array('field_show_novalue' => true), + 0, + 'Field should return correct raw value', + ), + ); + } + + /** + * @dataProvider get_profile_value_raw_data + */ + public function test_get_profile_value_raw($value, $field_options, $expected, $description) + { + $field_options = array_merge($this->field_options, $field_options); + + $result = $this->cp->get_profile_value_raw($value, $field_options); + + $this->assertSame($expected, $result, $description); + } + public function is_set_callback($field_id, $lang_id, $field_value) { return isset($this->dropdown_options[$field_value]); -- cgit v1.2.1