From 30cce1ed49f89dc7e6d246c3bece236472e172d9 Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Fri, 20 Jun 2014 19:06:04 +0530 Subject: [ticket/12730] Add unit test for type_googleplus PHPBB3-12730 --- tests/profilefields/type_googleplus_test.php | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/profilefields/type_googleplus_test.php (limited to 'tests') diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php new file mode 100644 index 0000000000..167f9eb688 --- /dev/null +++ b/tests/profilefields/type_googleplus_test.php @@ -0,0 +1,62 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +class phpbb_profilefield_type_googleplus_test extends phpbb_test_case +{ + public function get_profile_contact_value_data() + { + return array( + array( + '112010191010100', + array(), + '112010191010100', + 'Field should return a numerical Google+ ID as is', + ), + array( + 'TestUsername', + array(), + '+TestUsername', + 'Field should return a string Google+ ID with a + prefixed', + ), + ); + } + + /** + * @dataProvider get_profile_contact_value_data + */ + public function test_get_profile_contact_value($value, $field_options, $expected, $description) + { + $user = $this->getMock('\phpbb\user'); + $request = $this->getMock('\phpbb\request\request'); + $template = $this->getMock('\phpbb\template\template'); + + $field = new \phpbb\profilefields\type\type_googleplus( + $request, + $template, + $user + ); + + $default_field_options = array( + 'field_type' => '\phpbb\profilefields\type\type_googleplus', + 'field_name' => 'field', + 'field_id' => 1, + 'lang_id' => 1, + 'lang_name' => 'field', + 'field_required' => false, + 'field_validation' => '.*', + ); + $field_options = array_merge($default_field_options, $field_options); + + $this->assertSame($expected, $field->get_profile_contact_value($value, $field_options), $description); + } +} \ No newline at end of file -- cgit v1.2.1