1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-08 17:56:52 +02:00

Merge pull request #2647 from Dragooon/ticket/12334

[ticket/12334] Add PROFILE_FIELD_VALUE_RAW template var

* Dragooon/ticket/12334:
  [ticket/12334] Remove profile fields test group
  [ticket/12334] Add additional test for type_string
  [ticket/12334] Add string test for type_int
  [ticket/12334] Improve type_dropdown's test description
  [ticket/12334] Group profile fields test
  [ticket/12334] Change get_profile_value_raw_data to profile_value_raw_data
  [ticket/12334] Add get_profile_value_raw unit test for type_bool
  [ticket/12334] Add get_profile_value_raw unit test for type_date
  [ticket/12334] Add get_profile_value_raw unit tests for type_dropdown
  [ticket/12334] Add get_profile_value_raw unit test for type_string
  [ticket/12334] Add get_profile_value_raw unit test for type_url
  [ticket/12334] Add get_profile_value_raw unit tests for type_int
  [ticket/12334] Removed tests
  [ticket/12334] Dropdowns cannot be tested this way
  [ticket/12334] Added test get_profile_value_raw
  [ticket/12334] Changed from valueid to value_raw
  [ticket/12334] Implemented get_profile_valueid method
  [ticket/12334] Added field_novalue fall-back as requested
  [ticket/12334] Add PROFILE_FIELD_VALUEID template var
This commit is contained in:
Joas Schilling
2014-07-03 11:21:16 +02:00
13 changed files with 380 additions and 18 deletions

View File

@@ -74,10 +74,10 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
{
return array(
array(
false,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should not accept empty values for required fields',
false,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should not accept empty values for required fields',
),
);
}
@@ -130,6 +130,54 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
public function 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),
null,
'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),
null,
'Field should return correct raw value',
),
);
}
/**
* @dataProvider 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->options[$field_value]);

View File

@@ -179,6 +179,42 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
public function profile_value_raw_data()
{
return array(
array(
'',
array('field_show_novalue' => false),
null,
'Field should return the correct raw value',
),
array(
'',
array('field_show_novalue' => true),
'',
'Field should return correct raw value',
),
array(
'12/06/2014',
array('field_show_novalue' => true),
'12/06/2014',
'Field should return correct raw value',
),
);
}
/**
* @dataProvider 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 return_callback_implode()
{
return implode('-', func_get_args());

View File

@@ -170,6 +170,54 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
public function 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 null for empty value without show_novalue',
),
array(
'',
array('field_show_novalue' => true),
0,
'Field should return 0 for empty value with show_novalue',
),
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 0 for empty value with show_novalue',
),
);
}
/**
* @dataProvider 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]);

View File

@@ -169,6 +169,66 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
public function profile_value_raw_data()
{
return array(
array(
'10',
array('field_show_novalue' => true),
10,
'Field should return the correct raw value',
),
array(
'0',
array('field_show_novalue' => true),
0,
'Field should return correct raw value',
),
array(
'',
array('field_show_novalue' => true),
0,
'Field should return correct raw value',
),
array(
'10',
array('field_show_novalue' => false),
10,
'Field should return the correct raw value',
),
array(
'0',
array('field_show_novalue' => false),
0,
'Field should return correct raw value',
),
array(
'',
array('field_show_novalue' => false),
null,
'Field should return correct raw value',
),
array(
'string',
array('field_show_novalue' => false),
0,
'Field should return int cast of passed string'
),
);
}
/**
* @dataProvider 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 return_callback_implode()
{
return implode('-', func_get_args());

View File

@@ -225,6 +225,60 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
public function profile_value_raw_data()
{
return array(
array(
'[b]bbcode test[/b]',
array('field_show_novalue' => true),
'[b]bbcode test[/b]',
'Field should return the correct raw value',
),
array(
'[b]bbcode test[/b]',
array('field_show_novalue' => false),
'[b]bbcode test[/b]',
'Field should return correct raw value',
),
array(
125,
array('field_show_novalue' => false),
125,
'Field should return value of integer as is',
),
array(
0,
array('field_show_novalue' => false),
null,
'Field should return null for empty integer without show_novalue',
),
array(
0,
array('field_show_novalue' => true),
0,
'Field should return 0 for empty integer with show_novalue',
),
array(
null,
array('field_show_novalue' => true),
null,
'field should return null value as is',
),
);
}
/**
* @dataProvider 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 return_callback_implode()
{
return implode('-', func_get_args());

View File

@@ -104,6 +104,36 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
public function profile_value_raw_data()
{
return array(
array(
'http://example.com',
array('field_show_novalue' => true),
'http://example.com',
'Field should return the correct raw value',
),
array(
'http://example.com',
array('field_show_novalue' => false),
'http://example.com',
'Field should return correct raw value',
),
);
}
/**
* @dataProvider 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 return_callback_implode()
{
return implode('-', func_get_args());