Skip to content

Commit 90b126e

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 74abe7b commit 90b126e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/phpunit/tests/formatting/ConvertInvalidEntries.php

Lines changed: 42 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,47 @@ 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+
$stdClass = new stdClass();
63+
$stdClass->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+
'array' => array(
87+
'input' => array( 1, 2, 3 ),
88+
'output' => '',
89+
),
90+
'object' => array(
91+
'input' => $stdClass,
92+
'output' => '',
93+
),
94+
);
95+
}
96+
5597
function test_escapes_lone_ampersands() {
5698
$this->assertSame( 'at&t', convert_chars( 'at&t' ) );
5799
}

0 commit comments

Comments
 (0)