Skip to content

Commit 238532b

Browse files
committed
Tests_Formatting_ConvertInvalidEntities: add test cases with unexpected data types
... to test the handling of these data types by the function.
1 parent 1722dcf commit 238532b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/phpunit/tests/formatting/ConvertInvalidEntries.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase {
77

88
/**
99
* @dataProvider data_convert_invalid_entities_strings
10+
* @dataProvider data_convert_invalid_entities_non_string
1011
*
1112
* @covers :: convert_invalid_entities
1213
*
@@ -52,6 +53,39 @@ public function data_convert_invalid_entities_strings() {
5253
);
5354
}
5455

56+
/**
57+
* Data provider to safeguard consistent handling on unexpected data types.
58+
*
59+
* @return array
60+
*/
61+
public function data_convert_invalid_entities_non_string() {
62+
$std_class = new stdClass();
63+
$std_class->property = 'value';
64+
65+
return array(
66+
'null' => array(
67+
'input' => null,
68+
'output' => null,
69+
),
70+
'false' => array(
71+
'input' => false,
72+
'output' => false,
73+
),
74+
'true' => array(
75+
'input' => true,
76+
'output' => true,
77+
),
78+
'int' => array(
79+
'input' => 7486,
80+
'output' => 7486,
81+
),
82+
'float' => array(
83+
'input' => 25.689,
84+
'output' => 25.689,
85+
),
86+
);
87+
}
88+
5589
function test_escapes_lone_ampersands() {
5690
$this->assertSame( 'at&t', convert_chars( 'at&t' ) );
5791
}

0 commit comments

Comments
 (0)