mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/12514] Convert spaces to tabs
PHPBB3-12514
This commit is contained in:
parent
9f478de2ca
commit
d1f517ad65
6 changed files with 825 additions and 825 deletions
|
@ -13,135 +13,135 @@
|
||||||
|
|
||||||
class phpbb_profilefield_type_bool_test extends phpbb_test_case
|
class phpbb_profilefield_type_bool_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $cp;
|
protected $cp;
|
||||||
protected $field_options = array();
|
protected $field_options = array();
|
||||||
protected $options = array();
|
protected $options = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up basic test objects
|
* Sets up basic test objects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$user = $this->getMock('\phpbb\user');
|
$user = $this->getMock('\phpbb\user');
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
$lang = $this->getMock('\phpbb\profilefields\lang_helper', array(), array(null, null));
|
$lang = $this->getMock('\phpbb\profilefields\lang_helper', array(), array(null, null));
|
||||||
|
|
||||||
$lang->expects($this->any())
|
$lang->expects($this->any())
|
||||||
->method('get_options_lang');
|
->method('get_options_lang');
|
||||||
|
|
||||||
$lang->expects($this->any())
|
$lang->expects($this->any())
|
||||||
->method('is_set')
|
->method('is_set')
|
||||||
->will($this->returnCallback(array($this, 'is_set_callback')));
|
->will($this->returnCallback(array($this, 'is_set_callback')));
|
||||||
|
|
||||||
$lang->expects($this->any())
|
$lang->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnCallback(array($this, 'get')));
|
->will($this->returnCallback(array($this, 'get')));
|
||||||
|
|
||||||
$request = $this->getMock('\phpbb\request\request');
|
$request = $this->getMock('\phpbb\request\request');
|
||||||
$template = $this->getMock('\phpbb\template\template');
|
$template = $this->getMock('\phpbb\template\template');
|
||||||
|
|
||||||
$this->cp = new \phpbb\profilefields\type\type_bool(
|
$this->cp = new \phpbb\profilefields\type\type_bool(
|
||||||
$lang,
|
$lang,
|
||||||
$request,
|
$request,
|
||||||
$template,
|
$template,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->field_options = array(
|
$this->field_options = array(
|
||||||
'field_type' => '\phpbb\profilefields\type\type_bool',
|
'field_type' => '\phpbb\profilefields\type\type_bool',
|
||||||
'field_name' => 'field',
|
'field_name' => 'field',
|
||||||
'field_id' => 1,
|
'field_id' => 1,
|
||||||
'lang_id' => 1,
|
'lang_id' => 1,
|
||||||
'lang_name' => 'field',
|
'lang_name' => 'field',
|
||||||
'field_required' => false,
|
'field_required' => false,
|
||||||
'field_default_value' => 1,
|
'field_default_value' => 1,
|
||||||
'field_length' => 1,
|
'field_length' => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
0 => 'Yes',
|
0 => 'Yes',
|
||||||
1 => 'No',
|
1 => 'No',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_profile_field_data()
|
public function validate_profile_field_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
false,
|
false,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should not accept empty values for required fields',
|
'Field should not accept empty values for required fields',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_profile_field_data
|
* @dataProvider validate_profile_field_data
|
||||||
*/
|
*/
|
||||||
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->validate_profile_field($value, $field_options);
|
$result = $this->cp->validate_profile_field($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function profile_value_data()
|
public function profile_value_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
false,
|
false,
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'No',
|
'No',
|
||||||
'Field should output the default value',
|
'Field should output the default value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
false,
|
false,
|
||||||
array('field_show_novalue' => false, 'field_length' => 2),
|
array('field_show_novalue' => false, 'field_length' => 2),
|
||||||
null,
|
null,
|
||||||
'Field should not show anything for empty value',
|
'Field should not show anything for empty value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
0,
|
0,
|
||||||
array(),
|
array(),
|
||||||
'Yes',
|
'Yes',
|
||||||
'Field should show the set value',
|
'Field should show the set value',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider profile_value_data
|
* @dataProvider profile_value_data
|
||||||
*/
|
*/
|
||||||
public function test_get_profile_value($value, $field_options, $expected, $description)
|
public function test_get_profile_value($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->get_profile_value($value, $field_options);
|
$result = $this->cp->get_profile_value($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_set_callback($field_id, $lang_id, $field_value)
|
public function is_set_callback($field_id, $lang_id, $field_value)
|
||||||
{
|
{
|
||||||
return isset($this->options[$field_value]);
|
return isset($this->options[$field_value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($field_id, $lang_id, $field_value)
|
public function get($field_id, $lang_id, $field_value)
|
||||||
{
|
{
|
||||||
return $this->options[$field_value];
|
return $this->options[$field_value];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function return_callback_implode()
|
public function return_callback_implode()
|
||||||
{
|
{
|
||||||
return implode('-', func_get_args());
|
return implode('-', func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,180 +13,180 @@
|
||||||
|
|
||||||
class phpbb_profilefield_type_date_test extends phpbb_test_case
|
class phpbb_profilefield_type_date_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $cp;
|
protected $cp;
|
||||||
protected $field_options;
|
protected $field_options;
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up basic test objects
|
* Sets up basic test objects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->user = $this->getMock('\phpbb\user');
|
$this->user = $this->getMock('\phpbb\user');
|
||||||
$this->user->expects($this->any())
|
$this->user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
$this->user->expects($this->any())
|
$this->user->expects($this->any())
|
||||||
->method('create_datetime')
|
->method('create_datetime')
|
||||||
->will($this->returnCallback(array($this, 'create_datetime_callback')));
|
->will($this->returnCallback(array($this, 'create_datetime_callback')));
|
||||||
|
|
||||||
$this->user->timezone = new DateTimeZone('UTC');
|
$this->user->timezone = new DateTimeZone('UTC');
|
||||||
$this->user->lang = array(
|
$this->user->lang = array(
|
||||||
'datetime' => array(),
|
'datetime' => array(),
|
||||||
'DATE_FORMAT' => 'm/d/Y',
|
'DATE_FORMAT' => 'm/d/Y',
|
||||||
);
|
);
|
||||||
|
|
||||||
$request = $this->getMock('\phpbb\request\request');
|
$request = $this->getMock('\phpbb\request\request');
|
||||||
$template = $this->getMock('\phpbb\template\template');
|
$template = $this->getMock('\phpbb\template\template');
|
||||||
|
|
||||||
$this->cp = new \phpbb\profilefields\type\type_date(
|
$this->cp = new \phpbb\profilefields\type\type_date(
|
||||||
$request,
|
$request,
|
||||||
$template,
|
$template,
|
||||||
$this->user
|
$this->user
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->field_options = array(
|
$this->field_options = array(
|
||||||
'field_type' => '\phpbb\profilefields\type\type_date',
|
'field_type' => '\phpbb\profilefields\type\type_date',
|
||||||
'field_name' => 'field',
|
'field_name' => 'field',
|
||||||
'field_id' => 1,
|
'field_id' => 1,
|
||||||
'lang_id' => 1,
|
'lang_id' => 1,
|
||||||
'lang_name' => 'field',
|
'lang_name' => 'field',
|
||||||
'field_required' => false,
|
'field_required' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function profile_value_data()
|
public function profile_value_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'01-01-2009',
|
'01-01-2009',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'01/01/2009',
|
'01/01/2009',
|
||||||
'Field should output the correctly formatted date',
|
'Field should output the correctly formatted date',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
null,
|
null,
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
null,
|
null,
|
||||||
'Field should leave empty value as is',
|
'Field should leave empty value as is',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'None',
|
'None',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'None',
|
'None',
|
||||||
'Field should leave invalid value as is',
|
'Field should leave invalid value as is',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider profile_value_data
|
* @dataProvider profile_value_data
|
||||||
*/
|
*/
|
||||||
public function test_get_profile_value($value, $field_options, $expected, $description)
|
public function test_get_profile_value($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->get_profile_value($value, $field_options);
|
$result = $this->cp->get_profile_value($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_profile_field_data()
|
public function validate_profile_field_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should reject value for being empty',
|
'Field should reject value for being empty',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'0125',
|
'0125',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'01-01-2012',
|
'01-01-2012',
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Field should accept a valid value',
|
'Field should accept a valid value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'40-05-2009',
|
'40-05-2009',
|
||||||
array(),
|
array(),
|
||||||
'FIELD_INVALID_DATE-field',
|
'FIELD_INVALID_DATE-field',
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'12-30-2012',
|
'12-30-2012',
|
||||||
array(),
|
array(),
|
||||||
'FIELD_INVALID_DATE-field',
|
'FIELD_INVALID_DATE-field',
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'string',
|
'string',
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'string',
|
'string',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
100,
|
100,
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
100,
|
100,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should reject value for being invalid',
|
'Field should reject value for being invalid',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
null,
|
null,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should reject value for being empty',
|
'Field should reject value for being empty',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
true,
|
true,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should reject value for being empty',
|
'Field should reject value for being empty',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_profile_field_data
|
* @dataProvider validate_profile_field_data
|
||||||
*/
|
*/
|
||||||
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->validate_profile_field($value, $field_options);
|
$result = $this->cp->validate_profile_field($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function return_callback_implode()
|
public function return_callback_implode()
|
||||||
{
|
{
|
||||||
return implode('-', func_get_args());
|
return implode('-', func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create_datetime_callback($time = 'now', \DateTimeZone $timezone = null)
|
public function create_datetime_callback($time = 'now', \DateTimeZone $timezone = null)
|
||||||
{
|
{
|
||||||
$timezone = $timezone ?: $this->user->timezone;
|
$timezone = $timezone ?: $this->user->timezone;
|
||||||
return new \phpbb\datetime($this->user, $time, $timezone);
|
return new \phpbb\datetime($this->user, $time, $timezone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,175 +13,175 @@
|
||||||
|
|
||||||
class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
|
class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $cp;
|
protected $cp;
|
||||||
protected $field_options = array();
|
protected $field_options = array();
|
||||||
protected $dropdown_options = array();
|
protected $dropdown_options = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up basic test objects
|
* Sets up basic test objects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$user = $this->getMock('\phpbb\user');
|
$user = $this->getMock('\phpbb\user');
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
$request = $this->getMock('\phpbb\request\request');
|
$request = $this->getMock('\phpbb\request\request');
|
||||||
$template = $this->getMock('\phpbb\template\template');
|
$template = $this->getMock('\phpbb\template\template');
|
||||||
|
|
||||||
$lang = $this->getMock('\phpbb\profilefields\lang_helper', array(), array(null, null));
|
$lang = $this->getMock('\phpbb\profilefields\lang_helper', array(), array(null, null));
|
||||||
|
|
||||||
$lang->expects($this->any())
|
$lang->expects($this->any())
|
||||||
->method('get_options_lang');
|
->method('get_options_lang');
|
||||||
|
|
||||||
$lang->expects($this->any())
|
$lang->expects($this->any())
|
||||||
->method('is_set')
|
->method('is_set')
|
||||||
->will($this->returnCallback(array($this, 'is_set_callback')));
|
->will($this->returnCallback(array($this, 'is_set_callback')));
|
||||||
|
|
||||||
$lang->expects($this->any())
|
$lang->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnCallback(array($this, 'get')));
|
->will($this->returnCallback(array($this, 'get')));
|
||||||
|
|
||||||
$this->cp = new \phpbb\profilefields\type\type_dropdown(
|
$this->cp = new \phpbb\profilefields\type\type_dropdown(
|
||||||
$lang,
|
$lang,
|
||||||
$request,
|
$request,
|
||||||
$template,
|
$template,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->field_options = array(
|
$this->field_options = array(
|
||||||
'field_type' => '\phpbb\profilefields\type\type_dropdown',
|
'field_type' => '\phpbb\profilefields\type\type_dropdown',
|
||||||
'field_name' => 'field',
|
'field_name' => 'field',
|
||||||
'field_id' => 1,
|
'field_id' => 1,
|
||||||
'lang_id' => 1,
|
'lang_id' => 1,
|
||||||
'lang_name' => 'field',
|
'lang_name' => 'field',
|
||||||
'field_required' => false,
|
'field_required' => false,
|
||||||
'field_validation' => '.*',
|
'field_validation' => '.*',
|
||||||
'field_novalue' => 0,
|
'field_novalue' => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->dropdown_options = array(
|
$this->dropdown_options = array(
|
||||||
0 => '<No Value>',
|
0 => '<No Value>',
|
||||||
1 => 'Option 1',
|
1 => 'Option 1',
|
||||||
2 => 'Option 2',
|
2 => 'Option 2',
|
||||||
3 => 'Option 3',
|
3 => 'Option 3',
|
||||||
4 => 'Option 4',
|
4 => 'Option 4',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_profile_field_data()
|
public function validate_profile_field_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
7,
|
7,
|
||||||
array(),
|
array(),
|
||||||
'FIELD_INVALID_VALUE-field',
|
'FIELD_INVALID_VALUE-field',
|
||||||
'Invalid value should throw error',
|
'Invalid value should throw error',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
true,
|
true,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
false,
|
false,
|
||||||
'Boolean would evaluate to 1 and hence correct value',
|
'Boolean would evaluate to 1 and hence correct value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'string',
|
'string',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'String should be rejected for value',
|
'String should be rejected for value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
2,
|
2,
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Valid value should not throw error'
|
'Valid value should not throw error'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
0,
|
0,
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Empty value should be acceptible',
|
'Empty value should be acceptible',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
0,
|
0,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Required field should not accept empty value',
|
'Required field should not accept empty value',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_profile_field_data
|
* @dataProvider validate_profile_field_data
|
||||||
*/
|
*/
|
||||||
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->validate_profile_field($value, $field_options);
|
$result = $this->cp->validate_profile_field($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function profile_value_data()
|
public function profile_value_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
1,
|
1,
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'Option 1',
|
'Option 1',
|
||||||
'Field should output the given value',
|
'Field should output the given value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
4,
|
4,
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
'Option 4',
|
'Option 4',
|
||||||
'Field should output the given value',
|
'Field should output the given value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'<No Value>',
|
'<No Value>',
|
||||||
'Field should output nothing for empty value',
|
'Field should output nothing for empty value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
null,
|
null,
|
||||||
'Field should simply output null for empty value',
|
'Field should simply output null for empty value',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider profile_value_data
|
* @dataProvider profile_value_data
|
||||||
*/
|
*/
|
||||||
public function test_get_profile_value($value, $field_options, $expected, $description)
|
public function test_get_profile_value($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->get_profile_value($value, $field_options);
|
$result = $this->cp->get_profile_value($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_set_callback($field_id, $lang_id, $field_value)
|
public function is_set_callback($field_id, $lang_id, $field_value)
|
||||||
{
|
{
|
||||||
return isset($this->dropdown_options[$field_value]);
|
return isset($this->dropdown_options[$field_value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($field_id, $lang_id, $field_value)
|
public function get($field_id, $lang_id, $field_value)
|
||||||
{
|
{
|
||||||
return $this->dropdown_options[$field_value];
|
return $this->dropdown_options[$field_value];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function return_callback_implode()
|
public function return_callback_implode()
|
||||||
{
|
{
|
||||||
return implode('-', func_get_args());
|
return implode('-', func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,164 +13,164 @@
|
||||||
|
|
||||||
class phpbb_profilefield_type_int_test extends phpbb_test_case
|
class phpbb_profilefield_type_int_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $cp;
|
protected $cp;
|
||||||
protected $field_options;
|
protected $field_options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up basic test objects
|
* Sets up basic test objects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$user = $this->getMock('\phpbb\user');
|
$user = $this->getMock('\phpbb\user');
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
$request = $this->getMock('\phpbb\request\request');
|
$request = $this->getMock('\phpbb\request\request');
|
||||||
$template = $this->getMock('\phpbb\template\template');
|
$template = $this->getMock('\phpbb\template\template');
|
||||||
|
|
||||||
$this->cp = new \phpbb\profilefields\type\type_int(
|
$this->cp = new \phpbb\profilefields\type\type_int(
|
||||||
$request,
|
$request,
|
||||||
$template,
|
$template,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->field_options = array(
|
$this->field_options = array(
|
||||||
'field_type' => '\phpbb\profilefields\type\type_int',
|
'field_type' => '\phpbb\profilefields\type\type_int',
|
||||||
'field_name' => 'field',
|
'field_name' => 'field',
|
||||||
'field_id' => 1,
|
'field_id' => 1,
|
||||||
'lang_id' => 1,
|
'lang_id' => 1,
|
||||||
'lang_name' => 'field',
|
'lang_name' => 'field',
|
||||||
'field_required' => false,
|
'field_required' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function profile_value_data()
|
public function profile_value_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'10',
|
'10',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
10,
|
10,
|
||||||
'Field should output integer value of given input',
|
'Field should output integer value of given input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'0',
|
'0',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
0,
|
0,
|
||||||
'Field should output integer value of given input',
|
'Field should output integer value of given input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
0,
|
0,
|
||||||
'Field should translate empty value to 0 as integer',
|
'Field should translate empty value to 0 as integer',
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
null,
|
null,
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
0,
|
0,
|
||||||
'Field should translate null value to 0 as integer',
|
'Field should translate null value to 0 as integer',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'10',
|
'10',
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
10,
|
10,
|
||||||
'Field should output integer value of given input',
|
'Field should output integer value of given input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'0',
|
'0',
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
0,
|
0,
|
||||||
'Field should output integer value of given input',
|
'Field should output integer value of given input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
null,
|
null,
|
||||||
'Field should leave empty value as is',
|
'Field should leave empty value as is',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
null,
|
null,
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
null,
|
null,
|
||||||
'Field should leave empty value as is',
|
'Field should leave empty value as is',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider profile_value_data
|
* @dataProvider profile_value_data
|
||||||
*/
|
*/
|
||||||
public function test_get_profile_value($value, $field_options, $expected, $description)
|
public function test_get_profile_value($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->get_profile_value($value, $field_options);
|
$result = $this->cp->get_profile_value($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_profile_field_data()
|
public function validate_profile_field_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'15',
|
'15',
|
||||||
array('field_minlen' => 10, 'field_maxlen' => 20, 'field_required' => true),
|
array('field_minlen' => 10, 'field_maxlen' => 20, 'field_required' => true),
|
||||||
false,
|
false,
|
||||||
'Field should accept input of correct boundaries',
|
'Field should accept input of correct boundaries',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'556476',
|
'556476',
|
||||||
array('field_maxlen' => 50000, 'field_required' => true),
|
array('field_maxlen' => 50000, 'field_required' => true),
|
||||||
'FIELD_TOO_LARGE-50000-field',
|
'FIELD_TOO_LARGE-50000-field',
|
||||||
'Field should reject value of greater value than max',
|
'Field should reject value of greater value than max',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'9',
|
'9',
|
||||||
array('field_minlen' => 10, 'field_required' => true),
|
array('field_minlen' => 10, 'field_required' => true),
|
||||||
'FIELD_TOO_SMALL-10-field',
|
'FIELD_TOO_SMALL-10-field',
|
||||||
'Field should reject value which is less than defined minimum',
|
'Field should reject value which is less than defined minimum',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
true,
|
true,
|
||||||
array('field_maxlen' => 20),
|
array('field_maxlen' => 20),
|
||||||
false,
|
false,
|
||||||
'Field should accept correct boolean value',
|
'Field should accept correct boolean value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'string',
|
'string',
|
||||||
array('field_maxlen' => 10, 'field_required' => true),
|
array('field_maxlen' => 10, 'field_required' => true),
|
||||||
false,
|
false,
|
||||||
'Field should accept correct string value',
|
'Field should accept correct string value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
null,
|
null,
|
||||||
array('field_minlen' => 1, 'field_maxlen' => 10, 'field_required' => true),
|
array('field_minlen' => 1, 'field_maxlen' => 10, 'field_required' => true),
|
||||||
'FIELD_TOO_SMALL-1-field',
|
'FIELD_TOO_SMALL-1-field',
|
||||||
'Field should not accept an empty value',
|
'Field should not accept an empty value',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_profile_field_data
|
* @dataProvider validate_profile_field_data
|
||||||
*/
|
*/
|
||||||
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->validate_profile_field($value, $field_options);
|
$result = $this->cp->validate_profile_field($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function return_callback_implode()
|
public function return_callback_implode()
|
||||||
{
|
{
|
||||||
return implode('-', func_get_args());
|
return implode('-', func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,192 +17,192 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||||
|
|
||||||
class phpbb_profilefield_type_string_test extends phpbb_test_case
|
class phpbb_profilefield_type_string_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $cp;
|
protected $cp;
|
||||||
protected $field_options;
|
protected $field_options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up basic test objects
|
* Sets up basic test objects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $request, $user, $cache;
|
global $request, $user, $cache;
|
||||||
|
|
||||||
$user = $this->getMock('\phpbb\user');
|
$user = $this->getMock('\phpbb\user');
|
||||||
$cache = new phpbb_mock_cache;
|
$cache = new phpbb_mock_cache;
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
$request = $this->getMock('\phpbb\request\request');
|
$request = $this->getMock('\phpbb\request\request');
|
||||||
$template = $this->getMock('\phpbb\template\template');
|
$template = $this->getMock('\phpbb\template\template');
|
||||||
|
|
||||||
$this->cp = new \phpbb\profilefields\type\type_string(
|
$this->cp = new \phpbb\profilefields\type\type_string(
|
||||||
$request,
|
$request,
|
||||||
$template,
|
$template,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->field_options = array(
|
$this->field_options = array(
|
||||||
'field_type' => '\phpbb\profilefields\type\type_string',
|
'field_type' => '\phpbb\profilefields\type\type_string',
|
||||||
'field_name' => 'field',
|
'field_name' => 'field',
|
||||||
'field_id' => 1,
|
'field_id' => 1,
|
||||||
'lang_id' => 1,
|
'lang_id' => 1,
|
||||||
'lang_name' => 'field',
|
'lang_name' => 'field',
|
||||||
'field_required' => false,
|
'field_required' => false,
|
||||||
'field_validation' => '.*',
|
'field_validation' => '.*',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_profile_field_data()
|
public function validate_profile_field_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should not accept empty values for required fields',
|
'Field should not accept empty values for required fields',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
null,
|
null,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_REQUIRED-field',
|
'FIELD_REQUIRED-field',
|
||||||
'Field should not accept empty values for required field',
|
'Field should not accept empty values for required field',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
0,
|
0,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
false,
|
false,
|
||||||
'Field should accept a non-empty input',
|
'Field should accept a non-empty input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'false',
|
'false',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
false,
|
false,
|
||||||
'Field should accept a non-empty input',
|
'Field should accept a non-empty input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
10,
|
10,
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
false,
|
false,
|
||||||
'Field should accept a non-empty input',
|
'Field should accept a non-empty input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'tas',
|
'tas',
|
||||||
array('field_minlen' => 2, 'field_maxlen' => 5),
|
array('field_minlen' => 2, 'field_maxlen' => 5),
|
||||||
false,
|
false,
|
||||||
'Field should accept value of correct length',
|
'Field should accept value of correct length',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
't',
|
't',
|
||||||
array('field_minlen' => 2, 'field_maxlen' => 5),
|
array('field_minlen' => 2, 'field_maxlen' => 5),
|
||||||
'FIELD_TOO_SHORT-2-field',
|
'FIELD_TOO_SHORT-2-field',
|
||||||
'Field should reject value of incorrect length',
|
'Field should reject value of incorrect length',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'this is a long string',
|
'this is a long string',
|
||||||
array('field_minlen' => 2, 'field_maxlen' => 5),
|
array('field_minlen' => 2, 'field_maxlen' => 5),
|
||||||
'FIELD_TOO_LONG-5-field',
|
'FIELD_TOO_LONG-5-field',
|
||||||
'Field should reject value of incorrect length',
|
'Field should reject value of incorrect length',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'H3110',
|
'H3110',
|
||||||
array('field_validation' => '[0-9]+'),
|
array('field_validation' => '[0-9]+'),
|
||||||
'FIELD_INVALID_CHARS_NUMBERS_ONLY-field',
|
'FIELD_INVALID_CHARS_NUMBERS_ONLY-field',
|
||||||
'Required field should reject characters in a numbers-only field',
|
'Required field should reject characters in a numbers-only field',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'<>"&%&><>',
|
'<>"&%&><>',
|
||||||
array('field_maxlen' => 10, 'field_minlen' => 2),
|
array('field_maxlen' => 10, 'field_minlen' => 2),
|
||||||
false,
|
false,
|
||||||
'Optional field should accept html entities',
|
'Optional field should accept html entities',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'ö ä ü ß',
|
'ö ä ü ß',
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Required field should accept UTF-8 string',
|
'Required field should accept UTF-8 string',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'This ö ä string has to b',
|
'This ö ä string has to b',
|
||||||
array('field_maxlen' => 10),
|
array('field_maxlen' => 10),
|
||||||
'FIELD_TOO_LONG-10-field',
|
'FIELD_TOO_LONG-10-field',
|
||||||
'Required field should reject an UTF-8 string which is too long',
|
'Required field should reject an UTF-8 string which is too long',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'ö äö äö ä',
|
'ö äö äö ä',
|
||||||
array('field_validation' => '[\w]+'),
|
array('field_validation' => '[\w]+'),
|
||||||
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
|
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
|
||||||
'Required field should reject UTF-8 in alpha only field',
|
'Required field should reject UTF-8 in alpha only field',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'Hello',
|
'Hello',
|
||||||
array('field_validation' => '[\w]+'),
|
array('field_validation' => '[\w]+'),
|
||||||
false,
|
false,
|
||||||
'Required field should accept a characters only field',
|
'Required field should accept a characters only field',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_profile_field_data
|
* @dataProvider validate_profile_field_data
|
||||||
*/
|
*/
|
||||||
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->validate_profile_field($value, $field_options);
|
$result = $this->cp->validate_profile_field($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function profile_value_data()
|
public function profile_value_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'test',
|
'test',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'test',
|
'test',
|
||||||
'Field should output the given value',
|
'Field should output the given value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'test',
|
'test',
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
'test',
|
'test',
|
||||||
'Field should output the given value',
|
'Field should output the given value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_show_novalue' => true),
|
array('field_show_novalue' => true),
|
||||||
'',
|
'',
|
||||||
'Field should output nothing for empty value',
|
'Field should output nothing for empty value',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_show_novalue' => false),
|
array('field_show_novalue' => false),
|
||||||
null,
|
null,
|
||||||
'Field should simply output null for empty vlaue',
|
'Field should simply output null for empty vlaue',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider profile_value_data
|
* @dataProvider profile_value_data
|
||||||
*/
|
*/
|
||||||
public function test_get_profile_value($value, $field_options, $expected, $description)
|
public function test_get_profile_value($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->get_profile_value($value, $field_options);
|
$result = $this->cp->get_profile_value($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function return_callback_implode()
|
public function return_callback_implode()
|
||||||
{
|
{
|
||||||
return implode('-', func_get_args());
|
return implode('-', func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,97 +15,97 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||||
|
|
||||||
class phpbb_profilefield_type_url_test extends phpbb_test_case
|
class phpbb_profilefield_type_url_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $cp;
|
protected $cp;
|
||||||
protected $field_options;
|
protected $field_options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up basic test objects
|
* Sets up basic test objects
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$user = $this->getMock('\phpbb\user');
|
$user = $this->getMock('\phpbb\user');
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
$request = $this->getMock('\phpbb\request\request');
|
$request = $this->getMock('\phpbb\request\request');
|
||||||
$template = $this->getMock('\phpbb\template\template');
|
$template = $this->getMock('\phpbb\template\template');
|
||||||
|
|
||||||
$this->cp = new \phpbb\profilefields\type\type_url(
|
$this->cp = new \phpbb\profilefields\type\type_url(
|
||||||
$request,
|
$request,
|
||||||
$template,
|
$template,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->field_options = array(
|
$this->field_options = array(
|
||||||
'field_type' => '\phpbb\profilefields\type\type_url',
|
'field_type' => '\phpbb\profilefields\type\type_url',
|
||||||
'field_name' => 'field',
|
'field_name' => 'field',
|
||||||
'field_id' => 1,
|
'field_id' => 1,
|
||||||
'lang_id' => 1,
|
'lang_id' => 1,
|
||||||
'lang_name' => 'field',
|
'lang_name' => 'field',
|
||||||
'field_required' => false,
|
'field_required' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate_profile_field_data()
|
public function validate_profile_field_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array('field_required' => true),
|
array('field_required' => true),
|
||||||
'FIELD_INVALID_URL-field',
|
'FIELD_INVALID_URL-field',
|
||||||
'Field should reject empty field that is required',
|
'Field should reject empty field that is required',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'invalidURL',
|
'invalidURL',
|
||||||
array(),
|
array(),
|
||||||
'FIELD_INVALID_URL-field',
|
'FIELD_INVALID_URL-field',
|
||||||
'Field should reject invalid input',
|
'Field should reject invalid input',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'http://onetwothree.example.io',
|
'http://onetwothree.example.io',
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Field should accept valid URL',
|
'Field should accept valid URL',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'http://example.com/index.html?param1=test¶m2=awesome',
|
'http://example.com/index.html?param1=test¶m2=awesome',
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Field should accept valid URL',
|
'Field should accept valid URL',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'http://example.com/index.html/test/path?document=get',
|
'http://example.com/index.html/test/path?document=get',
|
||||||
array(),
|
array(),
|
||||||
false,
|
false,
|
||||||
'Field should accept valid URL',
|
'Field should accept valid URL',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'http://example.com/index.html/test/path?document[]=DocType%20test&document[]=AnotherDoc',
|
'http://example.com/index.html/test/path?document[]=DocType%20test&document[]=AnotherDoc',
|
||||||
array(),
|
array(),
|
||||||
'FIELD_INVALID_URL-field',
|
'FIELD_INVALID_URL-field',
|
||||||
'Field should reject invalid URL having multi value parameters',
|
'Field should reject invalid URL having multi value parameters',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_profile_field_data
|
* @dataProvider validate_profile_field_data
|
||||||
*/
|
*/
|
||||||
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
public function test_validate_profile_field($value, $field_options, $expected, $description)
|
||||||
{
|
{
|
||||||
$field_options = array_merge($this->field_options, $field_options);
|
$field_options = array_merge($this->field_options, $field_options);
|
||||||
|
|
||||||
$result = $this->cp->validate_profile_field($value, $field_options);
|
$result = $this->cp->validate_profile_field($value, $field_options);
|
||||||
|
|
||||||
$this->assertSame($expected, $result, $description);
|
$this->assertSame($expected, $result, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function return_callback_implode()
|
public function return_callback_implode()
|
||||||
{
|
{
|
||||||
return implode('-', func_get_args());
|
return implode('-', func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue