diff options
-rw-r--r-- | tests/phpunit/tests/kses.php | 71 |
1 files changed, 61 insertions, 10 deletions
diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 256a3866ec..61baf0d0a1 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -551,18 +551,69 @@ EOF; } /** + * Data provider. + */ + public static function data_normalize_entities(): array { + return array( + /** + * These examples are from the wp_kses_normalize_entities function description. + */ + 'AT&T' => array( 'AT&T', 'AT&T' ), + ':' => array( ':', ':' ), + '&#XYZZY;' => array( '&#XYZZY;', '&#XYZZY;' ), + + 'Named ref &' => array( '♠', '♠' ), + 'Named ref &' => array( '♠', '♠' ), + 'Named ref ♠' => array( '♠', '♠' ), + 'Named ref ¹' => array( '¹', '¹' ), + 'Named ref ²' => array( '²', '²' ), + 'Named ref ³' => array( '³', '³' ), + 'Named ref ¼' => array( '¼', '¼' ), + 'Named ref ½' => array( '½', '½' ), + 'Named ref ¾' => array( '¾', '¾' ), + 'Named ref ∴' => array( '∴', '∴' ), + + 'Decimal ref 	 ( )' => array( '	', '	' ), + 'Decimal ref " (")' => array( '"', '"' ), + 'Decimal ref " (")' => array( '"', '"' ), + 'Decimal ref & (&)' => array( '&', '&' ), + "Decimal ref ' (')" => array( ''', ''' ), + 'Decimal ref 😍 (😍)' => array( '😍', '😍' ), + 'Decimal ref 😍 (😍)' => array( '😍', '😍' ), + + 'Hex ref 	 ( )' => array( '	', '	' ), + 'Hex ref " (")' => array( '"', '"' ), + 'Hex ref " (")' => array( '"', '"' ), + 'Hex ref & (&)' => array( '&', '&' ), + "Hex ref ' (')" => array( ''', ''' ), + 'Hex ref 😍 (😍)' => array( '😍', '😍' ), + 'Hex ref 😍 (😍)' => array( '😍', '😍' ), + + 'HEX REF " (")' => array( '"', '"' ), + 'HEX REF & (&)' => array( '&', '&' ), + "HEX REF ' (')" => array( ''', ''' ), + 'HEX REF 😍 (😍)' => array( '😍', '😍' ), + + 'Encoded named ref &' => array( '&', '&' ), + 'Encoded named ref &' => array( '&', '&' ), + 'Encoded named ref &' => array( '&', '&' ), + + /* + * The codepoint value here is outside of the valid unicode range whose + * maximum is 0x10FFFF or 1114111. + */ + 'Invalid decimal unicode �' => array( '�', '�' ), + 'Invalid hex unicode �' => array( '�', '�' ), + ); + } + + /** * @ticket 26290 + * + * @dataProvider data_normalize_entities */ - public function test_wp_kses_normalize_entities() { - $this->assertSame( '♠', wp_kses_normalize_entities( '♠' ) ); - - $this->assertSame( '¹', wp_kses_normalize_entities( '¹' ) ); - $this->assertSame( '²', wp_kses_normalize_entities( '²' ) ); - $this->assertSame( '³', wp_kses_normalize_entities( '³' ) ); - $this->assertSame( '¼', wp_kses_normalize_entities( '¼' ) ); - $this->assertSame( '½', wp_kses_normalize_entities( '½' ) ); - $this->assertSame( '¾', wp_kses_normalize_entities( '¾' ) ); - $this->assertSame( '∴', wp_kses_normalize_entities( '∴' ) ); + public function test_wp_kses_normalize_entities( string $input, string $expected ) { + $this->assertSame( $expected, wp_kses_normalize_entities( $input ) ); } /** |