aboutsummaryrefslogtreecommitdiffstats
path: root/tests/profilefields
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-08-08 15:03:33 +0200
committerMarc Alexander <admin@m-a-styles.de>2014-08-08 17:06:01 +0200
commita6b275de5cd96f7a2527958e510a628012041a93 (patch)
tree70fd671bd3665b3b11e39e643a585cb62e3f926a /tests/profilefields
parente4e7a8f8494922ee52d927cfcfe8b27d73452ced (diff)
downloadforums-a6b275de5cd96f7a2527958e510a628012041a93.tar
forums-a6b275de5cd96f7a2527958e510a628012041a93.tar.gz
forums-a6b275de5cd96f7a2527958e510a628012041a93.tar.bz2
forums-a6b275de5cd96f7a2527958e510a628012041a93.tar.xz
forums-a6b275de5cd96f7a2527958e510a628012041a93.zip
[ticket/12794] Properly validate google+ field against valid character set
PHPBB3-12794
Diffstat (limited to 'tests/profilefields')
-rw-r--r--tests/profilefields/type_googleplus_test.php54
1 files changed, 43 insertions, 11 deletions
diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php
index fdbdd86553..3e0af36a73 100644
--- a/tests/profilefields/type_googleplus_test.php
+++ b/tests/profilefields/type_googleplus_test.php
@@ -11,8 +11,27 @@
*
*/
+require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+
class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
{
+ protected $field;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $user = new \phpbb\user();
+ $user->add_lang('ucp');
+ $request = $this->getMock('\phpbb\request\request');
+ $template = $this->getMock('\phpbb\template\template');
+
+ $this->field = new \phpbb\profilefields\type\type_googleplus(
+ $request,
+ $template,
+ $user
+ );
+ }
public function get_profile_contact_value_data()
{
return array(
@@ -36,16 +55,6 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
*/
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',
@@ -57,6 +66,29 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
);
$field_options = array_merge($default_field_options, $field_options);
- $this->assertSame($expected, $field->get_profile_contact_value($value, $field_options), $description);
+ $this->assertSame($expected, $this->field->get_profile_contact_value($value, $field_options), $description);
+ }
+
+ public function data_validate_googleplus()
+ {
+ return array(
+ array('foobar', false),
+ array('2342340929304', false),
+ array('foo<bar', 'The field “googleplus” has invalid characters.'),
+ array('klkd.klkl', false),
+ array('kl+', 'The field “googleplus” has invalid characters.'),
+ array('foo=bar', 'The field “googleplus” has invalid characters.'),
+ array('..foo', 'The field “googleplus” has invalid characters.'),
+ array('foo..bar', 'The field “googleplus” has invalid characters.'),
+ );
+ }
+
+ /**
+ * @dataProvider data_validate_googleplus
+ */
+ public function test_validate_googleplus($input, $expected)
+ {
+ $field_data = array_merge(array('lang_name' => 'googleplus'), $this->field->get_default_option_values());
+ $this->assertSame($expected, $this->field->validate_string_profile_field('string', $input, $field_data));
}
}