1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-20 07:42:09 +02:00

[ticket/12514] Fix array formatting for tests

PHPBB3-12514
This commit is contained in:
Shitiz Garg 2014-06-20 14:47:20 +05:30
parent 3ac73a831a
commit 4472a492da
5 changed files with 241 additions and 241 deletions

View File

@ -98,22 +98,22 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
{
return array(
array(
false,
array('field_show_novalue' => true),
'No',
'Field should output the default value',
false,
array('field_show_novalue' => true),
'No',
'Field should output the default value',
),
array(
false,
array('field_show_novalue' => false, 'field_length' => 2),
null,
'Field should not show anything for empty value',
false,
array('field_show_novalue' => false, 'field_length' => 2),
null,
'Field should not show anything for empty value',
),
array(
0,
array(),
'Yes',
'Field should show the set value',
0,
array(),
'Yes',
'Field should show the set value',
),
);
}

View File

@ -63,22 +63,22 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
{
return array(
array(
'01-01-2009',
array('field_show_novalue' => true),
'01/01/2009',
'Field should output the correctly formatted date',
'01-01-2009',
array('field_show_novalue' => true),
'01/01/2009',
'Field should output the correctly formatted date',
),
array(
null,
array('field_show_novalue' => false),
null,
'Field should leave empty value as is',
null,
array('field_show_novalue' => false),
null,
'Field should leave empty value as is',
),
array(
'None',
array('field_show_novalue' => true),
'None',
'Field should leave invalid value as is',
'None',
array('field_show_novalue' => true),
'None',
'Field should leave invalid value as is',
),
);
}
@ -99,70 +99,70 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
{
return array(
array(
'',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being empty',
'',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being empty',
),
array(
'0125',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being invalid',
'0125',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being invalid',
),
array(
'01-01-2012',
array(),
false,
'Field should accept a valid value',
'01-01-2012',
array(),
false,
'Field should accept a valid value',
),
array(
'40-05-2009',
array(),
'FIELD_INVALID_DATE-field',
'Field should reject value for being invalid',
'40-05-2009',
array(),
'FIELD_INVALID_DATE-field',
'Field should reject value for being invalid',
),
array(
'12-30-2012',
array(),
'FIELD_INVALID_DATE-field',
'Field should reject value for being invalid',
'12-30-2012',
array(),
'FIELD_INVALID_DATE-field',
'Field should reject value for being invalid',
),
array(
'string',
array(),
false,
'Field should reject value for being invalid',
'string',
array(),
false,
'Field should reject value for being invalid',
),
array(
'string',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being invalid',
'string',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being invalid',
),
array(
100,
array(),
false,
'Field should reject value for being invalid',
100,
array(),
false,
'Field should reject value for being invalid',
),
array(
100,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being invalid',
100,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being invalid',
),
array(
null,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being empty',
null,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being empty',
),
array(
true,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being empty',
true,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should reject value for being empty',
),
);
}

View File

@ -77,40 +77,40 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
{
return array(
array(
7,
array(),
'FIELD_INVALID_VALUE-field',
'Invalid value should throw error',
7,
array(),
'FIELD_INVALID_VALUE-field',
'Invalid value should throw error',
),
array(
true,
array('field_required' => true),
false,
'Boolean would evaluate to 1 and hence correct value',
true,
array('field_required' => true),
false,
'Boolean would evaluate to 1 and hence correct value',
),
array(
'string',
array('field_required' => true),
'FIELD_REQUIRED-field',
'String should be rejected for value',
'string',
array('field_required' => true),
'FIELD_REQUIRED-field',
'String should be rejected for value',
),
array(
2,
array(),
false,
'Valid value should not throw error'
2,
array(),
false,
'Valid value should not throw error'
),
array(
0,
array(),
false,
'Empty value should be acceptible',
0,
array(),
false,
'Empty value should be acceptible',
),
array(
0,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Required field should not accept empty value',
0,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Required field should not accept empty value',
),
);
}
@ -131,28 +131,28 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
{
return array(
array(
1,
array('field_show_novalue' => true),
'Option 1',
'Field should output the given value',
1,
array('field_show_novalue' => true),
'Option 1',
'Field should output the given value',
),
array(
4,
array('field_show_novalue' => false),
'Option 4',
'Field should output the given value',
4,
array('field_show_novalue' => false),
'Option 4',
'Field should output the given value',
),
array(
'',
array('field_show_novalue' => true),
'<No Value>',
'Field should output nothing for empty value',
'',
array('field_show_novalue' => true),
'<No Value>',
'Field should output nothing for empty value',
),
array(
'',
array('field_show_novalue' => false),
null,
'Field should simply output null for empty value',
'',
array('field_show_novalue' => false),
null,
'Field should simply output null for empty value',
),
);
}

View File

@ -52,60 +52,60 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
{
return array(
array(
'10',
array('field_show_novalue' => true),
10,
'Field should output integer value of given input',
'10',
array('field_show_novalue' => true),
10,
'Field should output integer value of given input',
),
array(
'0',
array('field_show_novalue' => true),
0,
'Field should output integer value of given input',
'0',
array('field_show_novalue' => true),
0,
'Field should output integer value of given input',
),
array(
'',
array('field_show_novalue' => true),
0,
'Field should translate empty value to 0 as integer',
false,
'',
array('field_show_novalue' => true),
0,
'Field should translate empty value to 0 as integer',
false,
),
array(
null,
array('field_show_novalue' => true),
0,
'Field should translate null value to 0 as integer',
null,
array('field_show_novalue' => true),
0,
'Field should translate null value to 0 as integer',
),
array(
'10',
array('field_show_novalue' => false),
10,
'Field should output integer value of given input',
'10',
array('field_show_novalue' => false),
10,
'Field should output integer value of given input',
),
array(
'0',
array('field_show_novalue' => false),
0,
'Field should output integer value of given input',
'0',
array('field_show_novalue' => false),
0,
'Field should output integer value of given input',
),
array(
'',
array('field_show_novalue' => false),
null,
'Field should leave empty value as is',
'',
array('field_show_novalue' => false),
null,
'Field should leave empty value as is',
),
array(
null,
array('field_show_novalue' => false),
null,
'Field should leave empty value as is',
null,
array('field_show_novalue' => false),
null,
'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)
{
$field_options = array_merge($this->field_options, $field_options);
@ -119,47 +119,47 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
{
return array(
array(
'15',
array('field_minlen' => 10, 'field_maxlen' => 20, 'field_required' => true),
false,
'Field should accept input of correct boundaries',
'15',
array('field_minlen' => 10, 'field_maxlen' => 20, 'field_required' => true),
false,
'Field should accept input of correct boundaries',
),
array(
'556476',
array('field_maxlen' => 50000, 'field_required' => true),
'FIELD_TOO_LARGE-50000-field',
'Field should reject value of greater value than max',
'556476',
array('field_maxlen' => 50000, 'field_required' => true),
'FIELD_TOO_LARGE-50000-field',
'Field should reject value of greater value than max',
),
array(
'9',
array('field_minlen' => 10, 'field_required' => true),
'FIELD_TOO_SMALL-10-field',
'Field should reject value which is less than defined minimum',
'9',
array('field_minlen' => 10, 'field_required' => true),
'FIELD_TOO_SMALL-10-field',
'Field should reject value which is less than defined minimum',
),
array(
true,
array('field_maxlen' => 20),
false,
'Field should accept correct boolean value',
true,
array('field_maxlen' => 20),
false,
'Field should accept correct boolean value',
),
array(
'string',
array('field_maxlen' => 10, 'field_required' => true),
false,
'Field should accept correct string value',
'string',
array('field_maxlen' => 10, 'field_required' => true),
false,
'Field should accept correct string value',
),
array(
null,
array('field_minlen' => 1, 'field_maxlen' => 10, 'field_required' => true),
'FIELD_TOO_SMALL-1-field',
'Field should not accept an empty value',
null,
array('field_minlen' => 1, 'field_maxlen' => 10, 'field_required' => true),
'FIELD_TOO_SMALL-1-field',
'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)
{
$field_options = array_merge($this->field_options, $field_options);

View File

@ -60,88 +60,88 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
{
return array(
array(
'',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should not accept empty values for required fields',
'',
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should not accept empty values for required fields',
),
array(
null,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should not accept empty values for required field',
null,
array('field_required' => true),
'FIELD_REQUIRED-field',
'Field should not accept empty values for required field',
),
array(
0,
array('field_required' => true),
false,
'Field should accept a non-empty input',
0,
array('field_required' => true),
false,
'Field should accept a non-empty input',
),
array(
'false',
array('field_required' => true),
false,
'Field should accept a non-empty input',
'false',
array('field_required' => true),
false,
'Field should accept a non-empty input',
),
array(
10,
array('field_required' => true),
false,
'Field should accept a non-empty input',
10,
array('field_required' => true),
false,
'Field should accept a non-empty input',
),
array(
'tas',
array('field_minlen' => 2, 'field_maxlen' => 5),
false,
'Field should accept value of correct length',
'tas',
array('field_minlen' => 2, 'field_maxlen' => 5),
false,
'Field should accept value of correct length',
),
array(
't',
array('field_minlen' => 2, 'field_maxlen' => 5),
'FIELD_TOO_SHORT-2-field',
'Field should reject value of incorrect length',
't',
array('field_minlen' => 2, 'field_maxlen' => 5),
'FIELD_TOO_SHORT-2-field',
'Field should reject value of incorrect length',
),
array(
'this is a long string',
array('field_minlen' => 2, 'field_maxlen' => 5),
'FIELD_TOO_LONG-5-field',
'Field should reject value of incorrect length',
'this is a long string',
array('field_minlen' => 2, 'field_maxlen' => 5),
'FIELD_TOO_LONG-5-field',
'Field should reject value of incorrect length',
),
array(
'H3110',
array('field_validation' => '[0-9]+'),
'FIELD_INVALID_CHARS_NUMBERS_ONLY-field',
'Required field should reject characters in a numbers-only field',
'H3110',
array('field_validation' => '[0-9]+'),
'FIELD_INVALID_CHARS_NUMBERS_ONLY-field',
'Required field should reject characters in a numbers-only field',
),
array(
'&lt;&gt;&quot;&amp;%&amp;&gt;&lt;&gt;',
array('field_maxlen' => 10, 'field_minlen' => 2),
false,
'Optional field should accept html entities',
'&lt;&gt;&quot;&amp;%&amp;&gt;&lt;&gt;',
array('field_maxlen' => 10, 'field_minlen' => 2),
false,
'Optional field should accept html entities',
),
array(
'ö ä ü ß',
array(),
false,
'Required field should accept UTF-8 string',
'ö ä ü ß',
array(),
false,
'Required field should accept UTF-8 string',
),
array(
'This ö ä string has to b',
array('field_maxlen' => 10),
'FIELD_TOO_LONG-10-field',
'Required field should reject an UTF-8 string which is too long',
'This ö ä string has to b',
array('field_maxlen' => 10),
'FIELD_TOO_LONG-10-field',
'Required field should reject an UTF-8 string which is too long',
),
array(
'ö äö äö ä',
array('field_validation' => '[\w]+'),
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
'Required field should reject UTF-8 in alpha only field',
'ö äö äö ä',
array('field_validation' => '[\w]+'),
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
'Required field should reject UTF-8 in alpha only field',
),
array(
'Hello',
array('field_validation' => '[\w]+'),
false,
'Required field should accept a characters only field',
'Hello',
array('field_validation' => '[\w]+'),
false,
'Required field should accept a characters only field',
),
);
}
@ -162,28 +162,28 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
{
return array(
array(
'test',
array('field_show_novalue' => true),
'test',
'Field should output the given value',
'test',
array('field_show_novalue' => true),
'test',
'Field should output the given value',
),
array(
'test',
array('field_show_novalue' => false),
'test',
'Field should output the given value',
'test',
array('field_show_novalue' => false),
'test',
'Field should output the given value',
),
array(
'',
array('field_show_novalue' => true),
'',
'Field should output nothing for empty value',
'',
array('field_show_novalue' => true),
'',
'Field should output nothing for empty value',
),
array(
'',
array('field_show_novalue' => false),
null,
'Field should simply output null for empty vlaue',
'',
array('field_show_novalue' => false),
null,
'Field should simply output null for empty vlaue',
),
);
}