From c7e067c578362fd67580ef1ef230856e57171329 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Wed, 16 Mar 2022 03:04:40 +0000 Subject: [PATCH] Tests: Include special characters in term names for `wp_set_term_objects()`. Test `wp_set_term_objects()` using terms with special characters in the name, for example ampersand, bullet and other symbols and punctuation. Props kapacity, costdev. Fixes #53152. See #54725. git-svn-id: https://develop.svn.wordpress.org/trunk@52938 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term.php | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 4cc0701097..15783c58f2 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -252,6 +252,51 @@ class Tests_Term extends WP_UnitTestCase { $this->assertSame( 0, sanitize_term_field( 'parent', '', $term['term_id'], $this->taxonomy, 'raw' ) ); } + /** + * @ticket 53152 + * @dataProvider data_wp_set_term_objects_finds_term_name_with_special_characters + * + * @param string $name A term name containing special characters. + */ + public function test_wp_set_term_objects_finds_term_name_with_special_characters( $name ) { + $post_id = self::$post_ids[0]; + $expected = wp_set_object_terms( $post_id, $name, 'category', false ); + $actual = wp_set_object_terms( $post_id, $name, 'category', false ); + $this->assertEquals( $expected, $actual ); + } + + /** + * Data provider. + * + * @return array + */ + public function data_wp_set_term_objects_finds_term_name_with_special_characters() { + return array( + 'ampersand' => array( 'name' => 'Foo & Bar' ), + 'ndash and mdash' => array( 'name' => 'Foo – Bar' ), + 'trademark' => array( 'name' => 'Foo Bar™' ), + 'copyright' => array( 'name' => 'Foo Bar©' ), + 'registered' => array( 'name' => 'Foo Bar®' ), + 'degree' => array( 'name' => 'Foo ° Bar' ), + 'forward slash' => array( 'name' => 'Fo/o Ba/r' ), + 'back slash' => array( 'name' => 'F\oo \Bar' ), + 'multiply' => array( 'name' => 'Foo × Bar' ), + 'standalone diacritic' => array( 'name' => 'Foo Bāáǎàr' ), + 'acute accents' => array( 'name' => 'ááa´aˊ' ), + 'iexcel and iquest' => array( 'name' => '¡Foo ¿Bar' ), + 'angle quotes' => array( 'name' => '‹Foo« »Bar›' ), + 'curly quotes' => array( 'name' => '“F‘o„o‚ „ ‟ ‛B“a’r”' ), + 'bullet' => array( 'name' => 'Foo • Bar' ), + 'unencoded percent' => array( 'name' => 'Foo % Bar' ), + 'encoded ampersand' => array( 'name' => 'Foo & Bar' ), + 'encoded ndash and mdash' => array( 'name' => 'Foo — – Bar' ), + 'encoded trademark' => array( 'name' => 'Foo Bar ™' ), + 'encoded copyright' => array( 'name' => 'Foo Bar ©' ), + 'encoded registered' => array( 'name' => 'Foo Bar ®' ), + 'encoded bullet' => array( 'name' => 'Foo • Bar' ), + ); + } + /** * @ticket 19205 */