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 From b50744ae0902d7f3e080e4caac126b8dad8b61fe Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Fri, 20 Jun 2014 20:57:52 +0530 Subject: [ticket/12730] Missing newline at type_googleplus_test.php PHPBB3-12730 --- tests/profilefields/type_googleplus_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php index 167f9eb688..389f101260 100644 --- a/tests/profilefields/type_googleplus_test.php +++ b/tests/profilefields/type_googleplus_test.php @@ -59,4 +59,4 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case $this->assertSame($expected, $field->get_profile_contact_value($value, $field_options), $description); } -} \ No newline at end of file +} -- cgit v1.2.1 From ea0e073c12b8c1f7136bc21dba0cf6e02aed1166 Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Fri, 20 Jun 2014 21:18:57 +0530 Subject: [ticket/12730] Add functional test for Google+ field PHPBB3-12730 --- tests/functional/ucp_profile_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/functional/ucp_profile_test.php b/tests/functional/ucp_profile_test.php index 2d68704162..e7abba9255 100644 --- a/tests/functional/ucp_profile_test.php +++ b/tests/functional/ucp_profile_test.php @@ -26,6 +26,7 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(array( 'pf_phpbb_facebook' => 'phpbb', + 'pf_phpbb_googleplus' => 'phpbb', 'pf_phpbb_location' => 'Bertie“s Empire', 'pf_phpbb_skype' => 'phpbb.skype.account', 'pf_phpbb_twitter' => 'phpbb_twitter', @@ -39,6 +40,7 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(); $this->assertEquals('phpbb', $form->get('pf_phpbb_facebook')->getValue()); + $this->assertEquals('phpbb', $form->get('pf_phpbb_googleplus')->getValue()); $this->assertEquals('Bertie“s Empire', $form->get('pf_phpbb_location')->getValue()); $this->assertEquals('phpbb.skype.account', $form->get('pf_phpbb_skype')->getValue()); $this->assertEquals('phpbb_twitter', $form->get('pf_phpbb_twitter')->getValue()); -- cgit v1.2.1 From ff057dfc8ec2dd195b263d9ffb4afc5051c52896 Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Sat, 21 Jun 2014 03:49:59 +0530 Subject: [ticket/12730] Fix type_googleplus_test to use same validation rule as the field PHPBB3-12730 --- tests/profilefields/type_googleplus_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php index 389f101260..fdbdd86553 100644 --- a/tests/profilefields/type_googleplus_test.php +++ b/tests/profilefields/type_googleplus_test.php @@ -53,7 +53,7 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case 'lang_id' => 1, 'lang_name' => 'field', 'field_required' => false, - 'field_validation' => '.*', + 'field_validation' => '[\w]+', ); $field_options = array_merge($default_field_options, $field_options); -- cgit v1.2.1